[fxruby-users] programmatically "pushing" a button
lyle at lylejohnson.name
Wed Dec 19 08:28:07 EST 2007
On Dec 18, 2007, at 1:08 PM, Thomas, Jason M ((Software)) wrote:
> I'm trying to use the Ruby unit test framework to exercise my
> FxRuby application. I have access to my button but I don't know how
> to programmatically "push" it. I tried the following:
> button.handle(button, MKUINT(FXWindow::ID_ENABLE, SEL_COMMAND), nil)
> This appears to have no effect at all. What am I doing wrong?
SEL_COMMAND is a message that the button sends to its target after
the user presses, then releases the left mouse button. In the code
you posted, you're sending a SEL_COMMAND message to the button, with
the ID_ENABLE message identifier, which just tells the button to
enable itself. It's a valid message to send to the button, but it's
not going to accomplish what you're after.
I haven't tried this, but I suppose you could simulate a button press
and release by sending a SEL_LEFTBUTTONPRESS message to the button,
followed by a SEL_LEFTBUTTONRELEASE message, e.g.
button.handle(nil, FXSEL(SEL_LEFTBUTTONPRESS, 0), nil)
button.handle(nil, FXSEL(SEL_LEFTBUTTONRELEASE, 0), nil)
In theory, that ought to then cause the button to fire off its
SEL_COMMAND message, just as if someone had pressed and released the
Hope this helps,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fxruby-users