Jivan Amara wrote:
>> I'd like to know from some of the more experienced users how they usually go 
>> about updating the children Widgets of a Window.
> 
> Sorry if I wasn't clear.  By update, I mean modify, like calling the child 
> Widget's deactivate/activate/show/hide members.
> 
> I'd like a simple way to choose a widget and call one of its members.  
> Putting the Widget's name in user_data and cycling through all the widgets of 
> a Window to find the one I want works, I was just wondering if there's a more 
> straightforward solution.

As others wrote already, using the children() to find a particular 
widget is not useful. For a small app with only one group (window) this 
may be a solution, but for bigger apps the set of widgets will usually 
become a tree of groups that will be difficult and ineffective to search 
for a particular widget. And comparing name strings is ineffective, too.

Using pointers or embedded widgets in other composite widgets is IMHO 
the only useful way to go. Again, for small apps, global pointer 
variables may be a first step, but for bigger apps you will need to 
arrange the pointers as members of other widgets, or as given by your 
application logic.

Another point that should be mentioned: I don't recommend using 
userdata() for anything else than being the callback argument that will 
be passed to a callback as its 2nd argument. Even if you think that you 
don't need it this way (Greg showed an example) then I wouldn't use it 
for anything else, because some time later somebody (not necessary you 
as the original author) _will_ start using callbacks where you didn't 
think of it in the first place, and then setting the callback with a 
userdata argument will overwrite your userdata() pointer (or vice versa).

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to