Listen for messages in FrontScripts

Todd Geist todd at geistinteractive.com
Tue Jan 3 15:01:37 EST 2012


On Tue, Jan 3, 2012 at 10:09 AM, Bob Sneidar <bobs at twft.com> wrote:

> If I am not mistaken, sent or dispatched messages are always sent to the
> card if another target is not specified,


hmm, Not what I see

Send, dispatch, and call use the current object as the target if none is
specified. It would only be the card if the card was the object sending the
command. Throw this in a button,

*on* mouseUp

   *send* test

*end* mouseUp


*on* test

   *put* the target

*end* test


When you click the button you will see that the message is handled by the
object.


If you send a message using *Any* form (send, dispatch or call) and do not
specify a target, then the object that is sending (or  calling or
dispatching)  the message is the target.  Of course a front script is
inserted before the target and can handle the message, BUT it is not "the
target".


Here is my current understanding of the differences in Send, Dispatch, and
Call. If anyone could correct me, I would appreciate it.


I think dispatch does switch contexts.  It send the message to the object
and it is processed along the normal message path.  It does have a special
use of the "me" object which can refer to a behavior. But other than that I
am pretty sure that references are evaluated in the context of the
receiving object, not the sending one.


Send is different because messages not handled but the target DO NOT
continue down the message path.  Send does NOT resolve "me" to the behavior
script if there is any. Like Dispatch the context is the receiving object,
not the sending one.


Call is really weird. Context is the CALLING object not the Sending object.
And messages that are not handled by the target pass down that object's
message Path.



Thanks


Todd

-- 
Todd Geist



More information about the use-livecode mailing list