[fxruby-users] Monitoring events/messages
David MacMahon
davidm at astro.berkeley.edu
Mon Jan 19 13:42:31 EST 2009
On Jan 19, 2009, at 7:45 , Lyle Johnson wrote:
> You can try setting the target for a particular widget to an
> FXDebugTarget instance. It should then print to the console all of
> the messages that that widget receives, e.g.
>
> button = FXButton.new(...)
> debug_target = FXDebugTarget.new
> button.target = debug_target
Thanks, Lyle,
I found FXDebugTarget after I had sent my message. That helps
somewhat, but it seems like it tells me all the events sent by a
widget rather than all the events received by a widget.
It seems like FXDebugTarget does not forward the event to any other
widget (i.e. the "real" target). I think it would be more useful if
FXDebugTarget's constructor accepted a target (optionally, defaulting
to nil). It would print the info as it does now and then pass the
event on to the given target (if it's not nil). This would make it
possible to insert and remove an FXDebugTarget at will while still
allowing the application to function normally...
# Insert FXDebugTarget to see events sent by button
button.target = FXDebugTarget.new(button.target)
# Remove FXDebugTarget from button
button.target = button.target.target
The remove operation assumes that FXDebugTarget has an attribute
named "target" that returns the original target. This could be a
problem if button's target is a regular widget rather than an
FXDebugTarget since that will set button's target to the other
widget's target, effectively bypassing button's original target. To
avoid this, perhaps FXDebugTarget's "target" attribute should be
called something else (e.g. "original_target"). Then the removal
would give an error button's target does not respond to
"original_target"...
# Safer removal of FXDebugTarget from button
button.target = button.target.original_target
With this proxying in place, I could walk the widget tree and add
FXDebugtargets to all the wdigets. Then I'd see all the events!
Thanks for FXRuby,
Dave
More information about the fxruby-users
mailing list