Re: [Fxruby-users] on/Event/ methods
Status: Inactive
Brought to you by:
lyle
|
From: <ly...@kn...> - 2003-08-12 17:07:48
|
On Tue, 12 Aug 2003 16:24:47 +0200, "Recheis Meinrad"
<Mei...@av...> wrote :
> several on... Methods are available in the module when i browse through
it. now i ask myself wether i can use them or not???
The onXXX() methods for a given class are its message handling methods for
different messages. That is to say, when the widget is sent a particular FOX
message (such as SEL_KEYPRESS), this is the method that will provide the
default behavior for that message, assuming that the widget has no target or
the target doesn't handle the message.
Message handler methods do not have to conform to any particular naming
scheme, but in most cases you can deduce which message a particular method
was intended to handle (e.g. "onMotion" handles SEL_MOTION messages).
In most cases you don't want to call the onXXX() methods directly. If you
want to change the default behavior for some message, you just #connect that
message to some handler block of code, or a method, i.e.
aWidget.connect(SEL_KEYPRESS) {
...
}
I guess the only time you'd want to call one of the onXXX() methods would be
when you actually subclass a widget. In that case, you might override the
onXXX() method in your derived class, then call the base class method using
super():
def onMotion(sender, sel, ptr)
# First, do some custom behavior in response to SEL_MOTION.
puts "foo"
# OK, now do the default behavior...
super
end
> i would like to alias onRightButtonPress in FXWindow in order to have a
Popup opening when i click on any widget of my gui.
There is no way to just globally change this behavior for every single
widget, since many of them already intercept (and possibly filter out) the
SEL_RIGHTBUTTONPRESS and SEL_RIGHTBUTTONRELEASE messages. But for a
particular widget of interest, you can catch this message and do something
about it with, for example,
someWidget.connect(SEL_RIGHTBUTTONRELEASE) {
...
}
Hope this helps,
Lyle
|