Re: Clearing widget events [message #35500 is a reply to message #35499] |
Wed, 18 June 2003 14:08   |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 18 Jun 2003 09:07:34 -0700, Ben Tupper wrote:
> Ian Dean wrote:
>> Hi All,
>> Is it possible to clear any pending widget events without causing
>> an
>> existing event handler to be called?
>>
>> I have some software that establishes an event handler using the
>> EVENT_PRO flag on a top-level base (I know I should use XMANAGER - but
>> this is not suitable in this case).
>> This works well, except that one function is time-consuming and
>> users
>> tend to hit the button (or other buttons) a number of times while
>> waiting.
>> What I would like to do is to clear the backlog of these events
>> when the
>> desired button action is complete.
>> I have tried using WIDGET_EVENT with /NO_WAIT until no event is
>> returned, but using this calls the current event handler, which I don't
>> want at this point. I have also tried setting the EVENT_PRO to a null
>> string before handling the desired function and then resetting it back
>> afterwards.
>> Neither of these methods are satisfactory and I was wondering if
>> there
>> is a better way.
>>
>> In anticipation,
>> Ian
>>
>>
>>
> Hello,
>
> I'm not sure how you are using the EVENT_PRO of your top level base
> without using Xmanager - so I'm not 100% sure I even understand the
> problem. But that won't restrain me from making suggestions; all my
> best stuff comes out of bliss-rich ignorance!
>
> (1) There is the CLEAR_EVENTS keyword to WIDGET_CONTROL
>
> From online help IDL 5.6
>
> CLEAR_EVENTS
> This keyword applies to all widgets.
> If set, any events generated by the widget hierarchy rooted at Widget_ID
> which have arrived but have not been processed (via the WIDGET_EVENT
> procedure)are discarded.
>
Here's what I use, which isn't technically legal, using a forbidden
widget_info keyword as it does:
__wa=widget_info(/managed) & for i=0,n_elements(__wa)-1 do widget_control,__wa[i],/clear_events
I have this bound to a keystroke, which also does a retall, getting me
back in shape when a widget crashes with 100 motion events in the
queue.
JD
|
|
|