custom widget (Event) q's

View: New views
4 Messages — Rating Filter:   Alert me  

custom widget (Event) q's

by eddy-44 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi again,

I think my example is probably not a good one for my question, as I
*can* figure out what the parent is by looking up the instance
variables, and do what I need to there.

However, I'm am still curious as to the best way to use the fox message
passing framework to send messages in general.  As I understand it, the
connect method is for specifying when receiving a message and I found a
reference to sending or delegating messages in the regular Fox docs,
using ->handle  which doesn't work in ruby land.

Thanks,
Ed

_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: custom widget (Event) q's

by Lyle Johnson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Apr 25, 2009, at 2:20 PM, eddy wrote:

> However, I'm am still curious as to the best way to use the fox  
> message passing framework to send messages in general.  As I  
> understand it, the connect method is for specifying when receiving a  
> message and I found a reference to sending or delegating messages in  
> the regular Fox docs, using ->handle  which doesn't work in ruby land.

When you call connect(), e.g.

        widget.connect(SEL_COMMAND) { ... }

what happens is that FXRuby creates an "anonymous" target object who  
responds to the SEL_COMMAND message by executing your passed-in code  
block. It then makes this newly-created object the target of "widget".  
A call to connect() is thus a quick-and-dirty way to provide a message  
handler for the message(s) sent by a widget.

If you want to send a message to a widget (or more generally any FOX  
object), you should be able to use handle():

        receiver.handle(sender, FXSEL(SEL_COMMAND, message_identifier),  
message_data)

Here, "receiver" is the object that will receive the message. There  
are admittedly a bunch of different combinations of how this could  
work, and we probably don't cover all of those cases in the FXRuby-to-
FOX binding. If you discover that a particular combination of interest  
isn't working, please submit a bug report and (preferably) a patch to  
fix it.

Hope this helps,

Lyle
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: custom widget (Event) q's

by eddy-44 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the info.  That explanation makes it simple.  As I get
further into this, I'm sure I'll get confused again :)

Good book btw, any plans on a vol 2, for advanced FXRuby?


_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: custom widget (Event) q's

by Lyle Johnson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Apr 27, 2009, at 3:15 PM, eddy wrote:

> Thanks for the info.  That explanation makes it simple.  As I get  
> further into this, I'm sure I'll get confused again :)
>
> Good book btw, any plans on a vol 2, for advanced FXRuby?

Thanks, I'm glad you enjoyed the FXRuby book. I'd like to find some  
time to publish some articles on advanced FXRuby topics, but a follow-
up book seems unlikely. The first book has sold better than I ever  
hoped it would, but it's not exactly a bestseller either. I'm doubtful  
that the publisher would be interested in a "sequel". ;)
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users