Re: [Fxruby-users] Message Identifiers, Types, etc again.
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <jl...@cf...> - 2003-06-13 16:10:27
|
Hugh Sasse Staff Elec Eng wrote: > Just when I thought I was no longer confused about this: > > On Thu, 12 Jun 2003, Hugh Sasse Staff Elec Eng wrote: > >> OK, reading this in conjunction with paragraphs 3 and 4 of >> >> http://www.fox-toolkit.org/messages.html >> >> it seems that message_id is actually the sender of the message, and >> message type is actually the message itself (not counting associated >> data). I would have called the message itself the message_id, > > Well, it is not as simple as that. The FXRuby API docs for > FXShutter, FXShutterItem, FXScrollbar and FXList at least refer to > Message Identifiers which are constants, and are not names of the > originating objects. So should these be called Message Types for > consistency with other FOX docs, or what? 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 for different reasons, and so one use for the identifier is to distinguish between different messages of the same type. If one of your GUI's buttons sends you a SEL_KEYPRESS message, you might react differently than you would if a text field sent the same message type. Following from that, a more general way to think about message identifiers is simply as a way to distinguish between different responses to the same type of message. Since you mentioned FXShutter in your post, let's work with an example based on that widget. Suppose you have a shutter widget: aShutter = FXShutter.new(...) and you want to provide some ways to open the first shutter item. One of those options that you're going to offer is a push button, somewhere on the GUI, so you construct that button: 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) 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. Let's say that you also want to provide a menu command (in a pulldown menu) that does the same thing. First you'd construct the menu command: openFirstMenuCommand = FXMenuCommand.new(...) and then set its target and identifier, as you did for the button: 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. Hope this helps, Lyle |