[fxruby-users] Monitoring events/messages
David MacMahon
davidm at astro.berkeley.edu
Sun Jan 18 14:20:49 EST 2009
I am trying to learn FXRuby (and Fox). I already know Ruby pretty
well. One thing that would help my understanding of FXRuby (and Fox)
is to be able to monitor (i.e. spy) on events that are sent to a
particular widget, class of widgets, or every widget. I tried to
accomplish this both by redefining the FXObject#handle as well as
creating my own subclass with its own #handle method. Neither way
did what I was hoping it would do.
Below is my modified hello.rb script. Can anyone tell me how to do
what I'm trying to do? Can it be done at all in FXRuby?
Thanks,
Dave
#!/usr/bin/env ruby
require 'fox16'
include Fox
class FXObject
alias :old_handle :handle
def handle(sender, selector, data)
p [self, sender, selector, data]
old_handle(sender, selector, data)
end
end
class MyApp < FXApp
def handle(sender, selector, data)
p ["MyApp", sender, selector, data]
super(sender, selector, data)
end
end
application = MyApp.new("Hello", "FoxTest")
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
FXButton.new(main, "&Hello, World!", nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()
More information about the fxruby-users
mailing list