Re: [Fxruby-users] Why doesn't 'handle' work like 'connect' in reverse?
Status: Inactive
Brought to you by:
lyle
|
From: Lyle J. <ly...@kn...> - 2004-04-18 21:16:52
|
On Apr 9, 2004, at 9:19 AM, Richard wrote:
> I'm trying to figure out how to get the method 'handle' to work.
You call handle() on a FOX object to send a FOX message to that object,
e.g.
obj.handle(sender, message, message_data)
> I've done something similar to:
> test_handle=FXButton.new(mainwin_reference,"Text for button").connect
> (SEL_COMMAND) { |sen,sel,data|
> puts "You've pressed me"
> puts sen
> puts sel
> puts data
> }
OK. You call connect() on a FOX object to register a message handler
for a particular message type that the object sends to its target. In
this case, you know that the FXButton sends a SEL_COMMAND message to
its message target whenever it (the button) is pressed, and you're
designating a special, hidden FOX object to handle that message that
the button sends. You can imagine it going something like this:
button = FXButton.new(...)
connectedObject = FXObject.new
button.target = connectedObject
The "connectedObject" is wired-up to listen for the SEL_COMMAND message
and execute the block you passed in. Of course, there's more to it than
that, but that's the basic idea ;)
> Then using that same information I call 'handle' using the button as a
> reference, but it doesn't trigger the "You've pressed me" statement
> (I don't have the code infront of me and I'd be afraid I'd mess it
> up.).
OK. You should do something like this:
button.handle(sender, MKUINT(0, SEL_COMMAND), null)
This sends the message to the button first. The button then forwards
the message to its target (the "connectedObject" that actually stores
your message-handler block).
> I know I'm using 'handle' semi-correctly, since I can get the button
> to look 'pressed' (and not released) I think it was ID_CHECKED or
> something like that (I went through all of the ID_WHATEVERS from the
> RDoc page on FXWindow), but I can't get the "You've pressed me"
> handler to fire.
>
> Thanks in advance for any help I get... What am I doing wrong?
Sounds like you're close; just use a zero for the first argument to
MKUINT() and I think you'll get the effect you're after.
Hope this helps,
Lyle
|