before

Typecontrol structure
DictionaryLCS
LibraryLiveCode Script
Syntax
before <messageName> [<parametersList>]
   <statementList>
end <messageName>
Summary

Defines a message handler.

Introduced6.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
messageName
parametersList
statementList
Example
before mouseUp
  answer "before mouse up received"
end mouseUp
RelatedKeyword: end, private
Command: dispatch
Function: result, commandNames, paramCount
Control Structure: after, on, exit
Glossary: message handler
Description

The before handler is exclusive to behavior scripts and is sent to a behavior script before all messages.

For example, consider a mouseDown message moving through the message path. It gets to an object with a behavior script:

  1. The engine looks at the behavior script of the target object - If a before mouseDown handler is present, it executes it.
  2. The engine next looks at the object script - If an on mouseDown handler is present, it executes it.
  3. The engine now looks at the behavior script - If an after mouseDown handler is present, it executes it.
  4. The engine finally looks at the object script - If a pass mouseDown or no mouseDown handler is present, it moves on to the parent object.

A before handler allows developers to produce behavior scripts which can handle messages sent to a control without having any effect on the message path, unlike front and back scripts.