Livecode Wiki
Advertisement

Sends a message to an object via the normal message path. Send command it's usually more flexible.

Built-in Message handler[]

Syntax:

dispatch message [ to target ][ with argumentList ]

Examples:

dispatch "updateWidget"
dispatch "setList" with tNewList

Use the dispatch command to send a message to an object, via the message path and find out whether it was handled or not. Parameters:

  • message - Is an expression that evaluates to the name of a handler.
  • target - Is a reference to any LiveCode object.
  • argumentList - Is a comma separated list of expressions containing the arguments to send.


Once finished, the variable it contains one of the following three values:

  • "handled" - the message was handled and not passed
  • "unhandled" - no matching handlers were found
  • "passed" - the message was handled but passed by all handlers


The dispatch command is most useful when using behaviors, as it allows a behavior script to send an 'event' to one of its child objects and then perform an action depending on the outcome.

Executing a dispatch command causes the message to be sent to the target object with the given argument list. This message passes through the message path in the normal way.

If no target is specified, the message is sent to 'me'. In the context of a behavior, this is typically the child that is executing rather than the behavior object itself.

See Also: send Command, behavior Property, me Keyword, it Keyword, closeControl Message, preOpenControl Message

Advertisement