Using Director > Writing Scripts with Lingo > Using handlers |
![]() ![]() ![]() |
Using handlers
As described in Using messages to identify events, Director sends messages to handlers within scripts when specific events occur. You attach a set of handlers to an object by attaching the handlers' script to the object. See Creating and attaching scripts with the Script window.
Each handler begins with the word on
followed by the message that the handler should respond to. The last line of the handler is the word end
. You can repeat the handler's name after end
, but this is optional.
When an object receives a message that corresponds to a handler attached to the object, Director runs the Lingo statements within the handler. For example, the mouseDown
message indicates that the user clicked the mouse button. To indicate in your script that an action should be performed when the mouse is clicked, you include a line in your script that begins with onMouseDown
. You follow this line with the Lingo statements that should execute when the script receives the mouseDown
message.
![]() ![]() ![]() |