[fxruby-users] fox/fxruby message and handler

Andreas S andreas_s at hotmail.com
Mon Feb 16 20:20:03 EST 2009

I couldn't figure out why my message-handler does not work. My test code is at the end of this email.

Case 1:
  The 'data' argument to the message handler comes out as an integer instead of my ruby string "joke". Can't I pass any ruby object? I've seen fxruby doc appendix C, where it is recommended to query the sender instead of interpreting the data. Is this the answer, don't pass data when sending message?

Case 2:
  This connect target is never executed. What did I do wrong?

I'm certain I must have misunderstood something here. I'd be happy if you can explain or point me to a doc or faq.

Many thanks in advance

(fxruby 1.6.18, fox 1.6, ruby 1.8.7)

class Label < FXLabel
  include Responder2
  include Responder

  attr_accessor :target

  def initialize *args
    identifier :ID_FUNNY

# Enable either case 1 or 2
# Case 1:
# End of case 1

# Case 2:
    connect SEL_COMMAND do
       puts "In Connect"
# End of case 2

  def funny sender, selector, data
     puts "Data is #{data}"

app = FXApp.new "a", "b"
win = FXMainWindow.new app, "c", :width => 40, :height => 300
frame = FXVerticalFrame.new win
label = Label.new frame, "Label"
button = FXButton.new frame, "Button"
button.connect SEL_COMMAND do
  label.handle b1, FXSEL(SEL_COMMAND, Label::ID_FUNNY, "joke")

See how Windows Mobile brings your life together—at home, work, or on the go.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090217/66f93a56/attachment-0001.html>

More information about the fxruby-users mailing list