[fxruby-users] fox/fxruby message and handler
Lyle Johnson
lyle at lylejohnson.name
Fri Feb 20 15:13:51 EST 2009
On Feb 17, 2009, at 6:25 PM, Andreas S wrote:
> The other part is my users asked me to improve my tool by allowing
> them to define bind keys.
> This got me looking at FXAccel. The following sample is from
> FXAccel#addAccel rdoc:
> hotKey = fxparseAccel("Ctrl+S")
> accelTable.addAccel(hotKey, doc, FXSEL(SEL_COMMAND,
> MyDocument::ID_SAVE))
> Seems like I can only associate a hot key with a message, not a
> block. That's why I'm looking
> into adding message selectors and handlers and my curiosity, for why
> my message handler doesn't
> work, won't leave my mind at peace. (I haven't been successful using
> FXAccelTable, but that's a
> different issue)
>
> My understanding was, given a list of selector types and ids,
> supported by a widget, widget#handle
> for FXSEL(TYPE,ID) will cause the widget to send FXSEL(TYPE,ID) to
> its target. But from what I
> gathered, one cannot be certain about that, as my button example
> shows.
Your understanding is correct; the problem is that the FXButton widget
doesn't respond to FXSEL(SEL_COMMAND, 0). This fact is unfortunately
not documented anywhere (other than in the FOX source code itself).
FXButton does, in contrast, respond to FXSEL(SEL_LEFTBUTTONPRESS, 0)
and FXSEL(SEL_LEFTBUTTONRELEASE, 0).
> I might not be able to rely on FXAccelTable to define bind keys,
> since #addAccel can only associate
> one hot key to one message type-id.
I know that I ran into some problem trying to support FXAccel#addAccel
with blocks. I think the problem was that FXAccelTable#addAccel
expects two arguments at the end (one for the "down" keypress and one
for the "up" keypress), but we can only pass one block, and so I
wasn't sure how to handle the association. It occurs to me that I
*might* be able to offer a different-looking API, something like:
addAccelUp(hotKey, target) do |sender, sel, ptr|
...
end
addAccelDown(hotKey) do |sender, sel, ptr|
...
end
or something like that...
Hope this helps,
Lyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090220/1b976c11/attachment-0001.html>
More information about the fxruby-users
mailing list