[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: realizing nonmodal widgets



Brian (reardonb@my-deja.com ) writes: 

> I have a TLB widget that contains a widget button called INPUT.  When
> INPUT is pressed a non modal dialog widget pops up on the screen to
> allow the user to input some data values.  Currently, if you press the
> INPUT widget button on the TLB a second time, then a second INPUT dialog
> widget opens up.  This is not what I want.  I would like IDL to bring
> the input widget to the foreground if it is already realized and if it
> is not, then I want IDL to realize it.  What is the most efficient or
> elegant way of doing this?  My naïve understanding is that I will have
> to use widget_info to determine if the widget has been realized and
> then, if so, somehow bring it to the foreground with widget_control but
> I am not sure.

Suppose that your input dialog widget is registered with XMANAGER
with a command like this:

   XMANAGER, 'input_dialog_thingy', tlb, Event_Hander=....

Then all you have to do to get the behavior you want is add
this line in your widget definition module (I.e., the one
where XMANAGER is called and the widgets are defined) *before*
you create any widgets:

   IF XRegistered('input_dialog_thingy') GT 0 THEN RETURN

This is how widget programs that use Common blocks protect
themselves from having multiple copies on the display at
once. :-)

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155