[fxruby-users] fox/fxruby message and handler

Andreas S andreas_s at hotmail.com
Tue Feb 17 19:25:05 EST 2009

Hi Lyle,

I'm grateful for your patience. 

> Date: Tue, 17 Feb 2009 14:04:56 -0600
> From: lyle at lylejohnson.name
> No. Generally speaking, the FXLabel widget doesn't respond to SEL_COMMAND.
> > I've used this approach in my code before...
> Right. The FXButton widget *does* respond to SEL_LEFTBUTTONPRESS and
> SEL_LEFTBUTTONRELEASE messages. But it's a different widget than the
> FXLabel widget. Different behavior.

Oh, I overlooked the selector TYPE. I was looking for how to add selector ID and I found it,
but I've forgotten about selector TYPE. Please forgive my stupidity.

> > 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.

After some tinkering, I found how to simulate that b1 click to trigger that 'puts "button1"'

b1 = FXButton.new(self, "Button1")
b1.connect(SEL_COMMAND) { puts "button1" }

# This never triggers b1 SEL_COMMAND
FXButton.new(self, "Button2").connect(SEL_COMMAND) { b1.handle self, FXSEL(SEL_COMMAND,0), nil }

# This does
FXButton.new(self, "Button2").connect(SEL_COMMAND) do
  b1.handle self, FXSEL(SEL_LEFTBUTTONPRESS,0), nil
  b1.handle self, FXSEL(SEL_LEFTBUTTONRELEASE,0), nil

> Could we back up a step or two? What is it that you're actually trying
> to accomplish? Are you trying to change the label's text whenever a
> button is pressed, or what?

In part, I'm exploring what I can or can't do. This particular issue caught my interest because it
looks like I have incorrect understanding and I wish to be corrected.

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.

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.


Stay up to date on your PC, the Web, and your mobile phone with Windows Live.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090218/0c1d816d/attachment.html>

More information about the fxruby-users mailing list