[fxruby-users] fox/fxruby message and handler

Andreas S andreas_s at hotmail.com
Tue Feb 17 14:15:46 EST 2009

> Date: Tue, 17 Feb 2009 09:19:41 -0600
> From: lyle at lylejohnson.name
> > Case 2:
> >   This connect target is never executed. What did I do wrong?
> You're calling connect(SEL_COMMAND) in the Label's initialize()
> method, which means you're calling connect(SEL_COMMAND) on the label
> itself. If the label widget actually sent a SEL_COMMAND to its target,
> the code in this block would get executed, but because the label
> doesn't send out any messages, this is basically inoperative code.

I have a line in my test where I call my label's handle method:

label = Label.new frame, "Label"
button = FXButton.new frame, "Button"
button.connect SEL_COMMAND do
  label.handle button, FXSEL(SEL_COMMAND, Label::ID_FUNNY, "joke")

Shouldn't this do the trick? I've used this approach in my code before. For example,
in my table, I made Ctrl-A to select all cells and I did it by sending message to table's
corner button, simulating a click (the snippet is at the end of this email, in case you'd
like to know). I believe this is the answer you gave in an old thread I found when googling
about simulating button click.

I tried to replace that Label with FXButton which will print something when it is clicked.
It does print it when I click it, but simulating a click still doesn't do it.

Thanks, Lyle. I appreciate you help.

class MyTable < FXTable
  def initialize *args
     connect SEL_KEYPRESS do |sender, selector, event|
        if event.state & CONTROLMASK != 0
          case event.code
          when KEY_a
            cornerButton.handle self, FXSEL(SEL_LEFTBUTTONPRESS, 0), event
            cornerButton.handle self, FXSEL(SEL_LEFTBUTTONRELEASE, 0), event

Get more out of the Web. Learn 10 hidden secrets of Windows Live.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090217/9f6cf5be/attachment.html>

More information about the fxruby-users mailing list