Re: Obtain all child widgets [message #81188 is a reply to message #81186] |
Mon, 20 August 2012 11:32  |
DavidF[1]
Messages: 94 Registered: April 2012
|
Member |
|
|
Russel writes:
> Ok, this must be easy and I'm just having "one of those days". I have a widget hierarchy, and it creates a series of buttons using the /menu feature in widget_button. But, I'd like to get the widget IDs of all the children. Suppose:
>
>
>
> base=widget_base(/col)
> but=widget_button(base,value='top',/menu)
> but1=widget_button(but,value='First level',/menu)
> b11=widget_button(but1,value='First button',uval='firstbutton',group=but)
> b12=widget_button(but1,value='Second button',uval='secondbutton',group=but)
> but2=widget_button(but,value='First level',/menu)
> b21=widget_button(but2,value='First button',uval='firstbutton',group=but)
> b22=widget_button(but2,value='Second button',uval='secondbutton',group=but)
>
> Now, I'd like to call something which will take as input the variable 'but' (as above) and return (in this example) a four element vector of widget IDs. I know widget_info(/child) but that only returns the first child. I suppose I could "nest" the group leaders, where the current button has the previous as a leader. Then just recursively call widget_info(/child), but that seems like a lot of work and requires the children be "serially" listed.
>
> I've scoured the widget_info and widget_control pages. It really feels like this should not only be possible, but pretty simple. I must be missing something...
You aren't missing anything. :-)
> Any ideas?
Take all those keystrokes where you are typing "group=but" (not needed)
and use them to save the button IDs you are interested in retaining into
the info structure of your program. Or, not. I haven't used
button IDs in 10 years, probably. I just use the button value
in my button event handlers. Makes the code *much* easier to read! ;-)
Cheers,
David
|
|
|