Catching events within Widgets [message #5941] |
Fri, 08 March 1996 00:00 |
justin
Messages: 1 Registered: March 1996
|
Junior Member |
|
|
My problem is this: I have written a widget program with start and stop
buttons, the trouble is once the start button is pressed the called procedure
grabs control of IDL and so the stop button has no effect.
At present there is a flag defined in common blocks within the event handler
and the called procedure, and the procedure runs on a 'while flag eq 1' type
loop. When the stop button is pressed the flag should be set to zero so the
procedure 'hears about' it through the common block. The events do get
queued, yet they are never actioned on.
Is there anyway to check to see if any events are queued and if so action on
them, and do this within a procedure?
Without going into details, using the timer event just isn't suitable for my
procedure.
Thanks for any help,
Justin.
PS Should you reply could you email also since my news provider is expiring
articles every 24hours at best- thanks.
Justin Ashmall
Space Physics Group, Imperial College, London
email justin@ic.ac.uk or j.ashmall@ic.ac.uk
|
|
|
Re: Catching events within Widgets [message #5945 is a reply to message #5941] |
Fri, 08 March 1996 00:00  |
jlaw
Messages: 11 Registered: November 1995
|
Junior Member |
|
|
If you ignore some of the documentation, you can do this...
pro loop,ev
common ctl,ok,button1,button2,base
if ok eq 1 then return
ok = 1
i = 0
while ok do begin
i = i + 1
for j = 0 , 100 do void
widget_control,button1,set_value=string(i)
;
event=widget_event(base,/nowait)
; ^^^^^^^^^^^^^^^^^^^^^ Lets IDL find out whats going on in the world.
end
end
pro ender,ev
common ctl,ok,button1,button2,base
ok = 0
widget_control,button1,set_value='start'
return
end
pro starter
common ctl,ok,button1,button2,base
ok = 0
base=widget_base(/row)
button1 = widget_button(base,value='start',event_pro='loop')
button2 = widget_button(base,value='stop',event_pro='ender')
widget_control,base,/real
xmanager,'',base
return
end
|
|
|
Re: Catching events within Widgets [message #5946 is a reply to message #5941] |
Fri, 08 March 1996 00:00  |
rivers
Messages: 228 Registered: March 1991
|
Senior Member |
|
|
In article <4hpdpg$205@oban.cc.ic.ac.uk>, justin@ic.ac.uk (Justin) writes:
>
> My problem is this: I have written a widget program with start and stop
> buttons, the trouble is once the start button is pressed the called procedure
> grabs control of IDL and so the stop button has no effect.
> At present there is a flag defined in common blocks within the event handler
> and the called procedure, and the procedure runs on a 'while flag eq 1' type
> loop. When the stop button is pressed the flag should be set to zero so the
> procedure 'hears about' it through the common block. The events do get
> queued, yet they are never actioned on.
> Is there anyway to check to see if any events are queued and if so action on
> them, and do this within a procedure?
> Without going into details, using the timer event just isn't suitable for my
> procedure.
The fundamental problem is that IDL only allows a single thread of execution.
When you called your procedure it will run until completion because the only
way for the flag in your common block to get updated is for XMANAGER to call
your event handler and set the flag. But XMANAGER never gets to run (it is
just another IDL procedure) until your called procedure returns.
The behavior you describe is extremely desirable for many applications. It
will require IDL to support multi-threaded execution. Someday?
____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
|
|
|