RE: [Fxruby-users] FXPopup questions
Status: Inactive
Brought to you by:
lyle
From: Adam W. <ad...@ta...> - 2004-05-17 20:05:05
|
At 10:45 AM -0700 5/17/04, Oliver Smith wrote: > > 1. How can I remove all items from a FXPopup? I've tried destroying >> its children, but then I get empty menu items: >> > > myPopup.children.each { | option | >> option.destroy >> } > >You should probably use 'myPopup.removeChild(child)'. I believe the destroy >function is always handled by Fox or FXRuby internally, so you don't ever >need to call it. Watch out for 'children.each', though...the iterator can >screw up when you remove a child from the array in the middle of recursing >through it. You may want to duplicate the array first. Thanks for the quick reply! I used children.each instead of each_child for that reason. children.dup.each doesn't seems to behave any differently. As for removeChild, I should have mentioned that I had tried it. The result is a Segmentation Fault (in Windows 98) when I click on the popup. I tried rewriting the loop to avoid the iteration issue, with no better results: while myPopup.children.length > 0 myPopup.removeChild myPopup.children[0] end > > Now I'd like to choose which one is selected. How can I do that? > >I'm not sure what FXOption/FXOptionMenu are...I thought FXOption was a radio >button at first, but now it looks like something else. If what you want is >a radio button in a menu; i.e. you have a few options and the selected one >has a little circle next to it, you should do: The class takes care of selecting the appropriate item automatically when the user clicks it -- it becomes the item displayed when the user lets go of the mouse button and menu pops closed. I should have been clearer about what I want to do, which is to select an item in the same way, but programmatically. That said, checkRadio and uncheckRadio might be the way to do it -- I'll experiment! >So I guess I don't know what FXOption is, but the sample program dialog.rb >seems to use it, if that helps. I cribbed my initial code from the samples, as usual... -- Adam Wildavsky Extreme Programmer Tameware, LLC ad...@ta... http://www.tameware.com |