04-30-2007 07:33 AM
04-30-2007 07:43 AM
05-01-2007 06:11 PM
05-02-2007 03:30 AM
05-03-2007 09:35 AM
05-04-2007 05:09 AM
User callbacks must always return
0 unless they intend to swallow the event to which they are responding.
To swallow
the event, the callback should return 1.
Only user input (mouse click and keypress events) and commit
events can be swallowed.
If swallowed, no more callbacks are called for that
event. If a user input event is swallowed,
the user’s mouse click or keypress is
ignored. If a commit event is swallowed, it is not placed into the GetuserEvent queue
05-05-2007 01:34 PM
Unfortunately things are not so easy as the documentation makes them feel...
Your solution does not prevent the TAB key from switch to the next control, the reason being the order events are sent to the control callback. If you select the Operate tool in the UIR editor (the button with the small hand pressing buttons) and operate on the control, in the upper right corner of the editor you can see listed the events that are fired by your actions: you may notice that EVENT_KEYPRESS while pressing the TAB key is fired before EVENT_COMMIT. But in the callback you are handling the commit event and try to swallow it: this does not swallow the tab key event because this has already been fired, so the focus switches to the next control.
A different approach could be to avoid handling the commit event and operate only on KEYPRESS events but you need to intercept exactly all keys that switch focus to another control (tab, ctrl+tab and all shortcut keys that are assigned to other controls quite a long list may be!).
But it is true that also my solution has some problem: when the user clicks on another control, the warning popup fires and then the UIR is somewhat freezed (the caret is in the new control while the focus is still on the old one, no response to keyboard actions... only a new click anywhere on the panel unblocks the program!)
05-09-2007 01:54 AM
05-09-2007 02:22 PM
ovrabek, there's no need to apologize: there was nothing wrong with your posts! I am sorry if I let you feel uncomfortable or so.
Swallowing events is a powerful technique and was the first I myself attempted to solve vahid problem... unfortunately in this case the sum of events queued to the callback vanified its power.