Re: Passing info and destroying widgets... [message #15884 is a reply to message #15879] |
Mon, 21 June 1999 00:00   |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
"Robert S. Mallozzi" wrote:
> I believe you must use XMANAGER in blocking mode for
> this technique to work.
Here's an example which works in non-blocking mode:
;---cut here---
PRO TEST_EVENT, EVENT
;- Get pointer from top level base, then the info structure
widget_control, event.top, get_uvalue=ptr
info = *ptr
;- Handle the widget which caused this event
widget_control, event.id, get_uvalue=name
case 1 of
name eq 'Button 1' or name eq 'Button 2' : info.name = name
else : widget_control, event.top, /destroy
endcase
;- Update the info structure
*ptr = info
END
;----------------------------------------------------------- -----
FUNCTION TEST, PTR
;- Create widgets
tlb = widget_base(/column)
but1 = widget_button(tlb, value='Button 1', uvalue='Button 1')
but2 = widget_button(tlb, value='Button 2', uvalue='Button 2')
but3 = widget_button(tlb, value='Done', uvalue='Done')
widget_control, tlb, /realize
;- Create info structure, and store pointer in top level base
info = {name:''}
ptr = ptr_new(info)
widget_control, tlb, set_uvalue=ptr
;- Manage events
xmanager, 'test', tlb, /no_block
;- Return pointer to caller
return, ptr
END
;---cut here---
Multiple instances can be invoked, e.g.
ptr1 = test()
ptr2 = test()
ptr3 = test()
Then to find the the last selected button of any of the instances of the
dialog,
info = *ptr1
print, info.name
--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
|
|
|