[fxruby-users] Problem with FXSwitcher

Tobi tobi at gronom.de
Sat Jan 12 07:28:00 EST 2008

Thanks for your reply. I think, I forgot something to explain. If the  
user adds a picture to the program (like the example in your book),  
this picture is added to the switcher and set as the current item.  
This is an excerpt of my code.

class CardList < FXSwitcher
    def initialize(parent)
     @cards = []

   def add_card(card)
     @cards << card
     PictureView.new self, card
     self.setCurrent @cards.size-1, true



When I initialize the CardList, current is already set to 0. When I  
add the first picture, current is still 0. How can I fire a  
SEL_COMMAND at this point?

Thank you

Am 12.01.2008 um 13:02 schrieb Lyle Johnson:

> On Jan 12, 2008, at 5:21 AM, Grobie wrote:
>> I'm writing my first FXRuby program (with the help of Lyle Johnsons
>> Pragmatic book, thanks) and I've got a little problem with the
>> FXSwitcher.
>> I've got a form and a picture. When the user opens a new picture, I
>> want to
>> reload the form (so every picture has one form). This works,
>> FXSwitcher
>> fires a message and I can react. But if the switcher is empty (when
>> the
>> program starts) and I add the first picture to it, it doesn't fire.
>> Why? And
>> if it's impossible to do it my way, how can I fire a message  
>> manually?
> Tobias,
> The switcher only fires a SEL_COMMAND message when the index of its
> current window is changed from one child window to another. So for
> example if you are currently showing panel 2, and then you change to
> panel 3, it should fire SEL_COMMAND. However, merely adding a window
> to a switcher doesn't cause this index to change (nor does removing a
> window from the switcher).
> If you're wanting to fire a SEL_COMMAND every time a new panel is
> added to the switcher, you'd need to do something manually, e.g.
> 	switcher = FXSwitcher.new(...)
> 	...
> 	new_panel = FXVerticalFrame.new(switcher, ...)
> 	switcher.setCurrent(switcher.numChildren -1, true)
> Hope this helps,
> Lyle
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users

More information about the fxruby-users mailing list