[Fxruby-users] Re: [FXRuby] aliasing FXComboBox's methods
Status: Inactive
Brought to you by:
lyle
From: <ly...@kn...> - 2003-08-05 21:05:58
|
On Tue, 05 Aug 2003 22:56:48 +0200, meinrad recheis <mei...@gm...> wrote : > hope you are not angry for mailing directly to you, istead of posting on > the mailing list. No, that's no problem! > [FXRuby] aliasing FXComboBox's methods: > i want to change the combo's behavior so i aliased some of its interesting > methods. > unfortunately the strings won't be printed (no matter what i do with the > combobox) > that is, the alias-methods don_t get called. > got an idea why? I'm not sure I understand what you're trying to do. If you want to set up an alias for, say, FXComboBox#onListClicked, you can certainly do so with this code: class FXComboBox alias onListClicked click end With this alias in place, a call to 'click' is the same as a call to 'onListClicked', i.e. comboBox = FXComboBox.new(...) comboBox.onListClicked(x, y, z) comboBox.click(x, y, z) # same result as previous But this is just standard Ruby stuff. Now, if you are trying to catch the messages sent from an FXComboBox widget when one of its items is clicked, you want to instead use the connect() method to map the appropriate message to some handler method or block. According to the documentation for FXComboBox: http://www.fxruby.org/doc/api/classes/Fox/FXComboBox.html The combo box widget sends a SEL_COMMAND message when a new item is selected, so that's the one you want to catch: comboBox = FXComboBox.new(...) comboBox.connect(SEL_COMMAND) { |sender, sel, data| puts "click! new text = #{data}" } Hope this helps, Lyle |