comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: checking for pending events
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: checking for pending events [message #7622] Sat, 30 November 1996 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Chris Chase <chris.chase@jhuapl.edu> writes:

> Is there a way to check if events are pending?
>
> I have a widget program that has a "play" mode, i.e. it continuously
> updates using widget timer events (widget_control, wid, timer=1.0). I
> do not want to update until all previous events created by an update
> have been processed. During an update I use events as a natural way
> for updating various top-level widget hierarchies. I want these
> events and any cascading events they produce to be processed before
> doing another application update.
>
> I would like to be able to do something like:
>
> pro event_handler, ev
>
> case ev.id of
>
> wid.timer: begin
> if not widget_events_pending() then begin
> ;; perform update task
> endif
> widget_control, wid.timer, timer=.25
> end
> ....
> endcase
> return
> end

There is no way, as far as I know, to determine if a particular event
is pending. But I can think of a way to approach this problem that
might work in your particular application.

You can use the function WIDGET_EVENT to look at the event queue
for a particular widget and any of its children. If no events are
queued up for that widget or its children, the event structure that is
returned from the function has a 0 in the ID field. This would tell
you there are no more events pending, it's OK to do your updating.

The problem, of course, is what happens *IF* events are pending.
When you look at the event queue with WIDGET_EVENT, you get the
event structure of the first event pending on the queue.
What do you do with it? You could probably have a look-up table
of IDs and their corresponding event handlers and pass the event
along properly to the correct event handler, but this seems like a
lot of work and is the whole purpose of XMANAGER anyway.

But in your case, since the events you are looking for are update
events, what do you care in what order they are processed? Just
put the event back on the queue with WIDGET_CONTROL and the
SEND_EVENT keyword. Your code might look like this:

case ev.id of

wid.timer: begin
thisEvent = WIDGET_EVENT(tlb, /NOWAIT)
IF thisEvent.ID EQ 0 THEN BEGIN
; No updates pending, set next update event.
WIDGET_CONTROL, updateWidgetID, TIMER=0.25
ENDIF ELSE BEGIN
; Whoops, here is a pending event. Put it at end of current
queue.
WIDGET_CONTROL, thisEvent.ID, SEND_EVENT=thisEvent
; Come back and check again in a little bit.
WIDGET_CONTROL, ev.id, TIMER=0.1
ENDELSE
end

endcase

Anyway, it's a suggestion! :-)

David

*************************************************
* David Fanning, Ph.D.
* 2642 Bradbury Court, Fort Collins, CO 80521
* Phone: 970-221-0438 Fax: 970-221-4762
* E-Mail: davidf@dfanning.com
*
* Sometimes I go about pitying myself, and all along my
* soul is being blown by great winds across the sky.
* -- Ojibway saying
************************************************
[Message index]
 
Read Message
Previous Topic: Wind Barbs in IDL...
Next Topic: Re: changing of defined structures

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 17:45:36 PDT 2025

Total time taken to generate the page: 0.16223 seconds