Re: [Fxruby-users] Message Identifiers, Types, etc again.
Status: Inactive
Brought to you by:
lyle
|
From: Hugh S. S. E. E. <hg...@dm...> - 2003-06-13 16:41:10
|
On Fri, 13 Jun 2003, Lyle Johnson wrote:
>
> Message identifiers are not the same things as message types. Message
> identifiers *can* be used as a means of identifying the sender of a
> message, but that's just one use for them.
>
> Multiple objects can send the same type of message to a single receiver
[...]
> your post, let's work with an example based on that widget. Suppose you
> have a shutter widget:
>
> aShutter = FXShutter.new(...)
[...[
> openFirstButton = FXButton.new(...)
>
> When a button is clicked, it sends a SEL_COMMAND message to its message
> target. When this button (openFirstButton) is clicked, we want it to
> send a message to the shutter, so let's make the shutter its message target:
>
> openFirstButton.setTarget(aShutter)
(which could be used for the dynamic retargeting we discussed
earlier. OK...)
>
> The ID_OPEN_FIRST message identifier tells the shutter to open its first
> item, so let's make that the message identifier (or selector):
>
> openFirstButton.setSelector(FXShutter::ID_OPEN_FIRST)
>
> So now, when the user clicks this button, it will send a (SEL_COMMAND,
> ID_OPEN_FIRST) message to the shutter.
So this is sending the ID_OPEN_FIRST selector in the data part of
the (sender, message, data) triple? (Incidentally, I don't see
setSelector in the http://www.fxruby.org/doc/api/ but that's BTW.)
Does SEL_COMMAND have the semantics "If the data is a selector,
respond as if that had been the message", or am I overgeneralizing
now?
> Let's say that you also want to provide a menu command (in a pulldown
[...]
> openFirstMenuCommand = FXMenuCommand.new(...)
[...]
> openFirstMenuCommand.setTarget(aShutter)
> openFirstMenuCommand.setSelector(FXShutter::ID_OPEN_FIRST)
>
> Since a menu command sends a SEL_COMMAND message to its target when it
> is selected, this has exactly the same result as the button click did.
>
> Note that for this example, the message identifier (ID_OPEN_FIRST)
> doesn't distinguish between different senders, it's just identifying
> which command we want the shutter to perform.
Ok, so this is using message id to mean ( "don't care", message_type).
This is clearer now, but I must say I find this overloading of the
meaning confusing. I just wonder how many more things like this
there are to bite me!
>
> Hope this helps,
>
> Lyle
>
Thank you for your continued patience!
Hugh
|