The document discusses different types of messages in LiveCode and how they can be used to respond to user interactions and events. It covers mouse messages, field messages, open/close messages, keyboard messages, and mobile messages. Messages allow a program to "chat" with LiveCode to perform actions when events like button clicks or key presses occur. Handlers can be written to respond to specific messages and pass them along to other levels in the message hierarchy.
Convert to study guideBETA
Transform any presentation into a summarized study guide, highlighting the most important points and key insights.
3. What is a Message?
A message is indeed like a chat. When some
kind of event happens - like the user clicks a
button, LiveCode will send a message to
your the program.
The question is what do you want to do
when you get the message. Your reply is the
code you write in LiveCode. This is how you
“chat” with LiveCode.
Click Me
3
Calculator App
4. More on Messages
There are lots of more resources available
on the message path. They do a good job
explaining the concept.
As you can see in the video. The Dictionary
located in the LiveCode IDE will give you
full access on all events.
Some are much more advanced, like
Richard Gaskin’s Extending the LiveCode
Message path.
The LiveCode Message Path
Messages in LiveCode
Advanced [only for reference]:
Extending the LiveCode Message Path
LESSONS
4
Calculator App
5. This message hierarchy allows us to place
the code needed by several interface
controls into a higher level, available to all
of those controls.
One such case will be with the calculator's
number buttons; each one needs to do
exactly the same thing, and by putting that
code into the card level, each of them can
make use of that single handler.
Running the sample App and watching the video will
help you understand.
5
Calculator App
Message Path
6. The pass command tells LiveCode that after the
control has processed the message, it will be “passed”
up to the next level of the hierarchy along the
message path for a mouseUp handler, which could be
that in a group or card script, for example.
If an appropriate handler is found, it will then execute
that handler in the group or card script and stop
moving up the levels unless there is also a pass
command in that handler.
Note: When the pass command is executed, any remaining
statements in the handler are skipped, so this command is
almost always placed at the end of a handler or within an if-
control structure.
Pass
on mouseDown
beep
-- keep passing the message on
pass mouseDown
end mouseDown
6
Calculator App
7. mouseDown: Handle the mouseDown message to perform an action when the user presses the mouse
button, before the mouse button is released.
mouseEnter: Handle the mouseEnter message to perform an action (for example, display additional
information or highlight a button) when the mouse pointer enters an object.
mouseLeave: Handle the mouseLeave message to update a control when the mouse pointer moves
outside it.
mouseMove: Handle the mouseMove message if you want to perform some action (such as updating a
field) when the user moves the mouse, or if you want to keep continuous track of the mouse pointer's
position.
mouseUp: Handle the mouseUp message to perform an action when the user releases the mouse button
after clicking.
Mouse Messages
7
Calculator App
8. deleteField: Handle the deleteField message if you want to perform cleanup before a field is removed from
the stack.
enterInField: Handle the enterInField message when you want to perform an action when the user presses
Enter in a field.
exitField: Handle the exitField message if you want to do something when the user leaves a field that hasn't
been changed.
openField: Handle the openField message if you want to do something when the user enters a field.
returnInField: Handle the returnInField message when you want to perform an action (such as adding a
column of figures) when the user presses Return in a field.
Field Messages
8
Calculator App
9. deleteField: Handle the deleteField message if you want to perform cleanup before a field is removed from
the stack.
enterInField: Handle the enterInField message when you want to perform an action when the user presses
Enter in a field.
exitField: Handle the exitField message if you want to do something when the user leaves a field that hasn't
been changed.
openField: Handle the openField message if you want to do something when the user enters a field.
returnInField: Handle the returnInField message when you want to perform an action (such as adding a
column of figures) when the user presses Return in a field.
Field Messages
9
Calculator App
10. openBackground: Handle the openBackground message to change a group's objects, or perform other
updates, when a card with the group on it is opened.
preOpenCard: Handle the preOpenCard message to update a card's appearance before the card appears
on screen.
openCard: Handle the openCard message to change a card's objects, or perform other updates, when the
card is visited.
preOpenStack: Handle the preOpenStack message to update a card's appearance before the card
appears on screen.
openStack: Handle the openStack message to change a stack's objects, or perform other updates, when
the stack is opened.
Open/Close Messages
10
Calculator App
11. keyDown: Handle the keyDown message if you want to do something special when the user presses any
key or a particular key you check for in the handler.
keyUp: Handle the keyUp message if you want to do something special when the user releases any key (or
a particular key you check for in the handler).
deleteKey: Handle the deleteKey message if you want to do something special when the user presses the
forward delete key.
escapeKey: Handle the escapeKey message if you want to perform some action when the user presses
Escape.
tabKey: Handle the tabKey message when you want to perform an action (such as going to the next card)
when the user presses the Tab key.
Keyboard Messages
11
Calculator App
12. pushNotificationReceived: Sent when the application receives a push notification from a Push Notification
Server.
purchaseStateUpdate: Sent by the store to notify the app of any changes in state to the purchase request.
movieTouched: Handle the movieTouched message to perform an action when a full screen movie is
playing and the user touches the screen.
adLoaded: Sent when an ad had loaded (or reloaded).
adClicked: Handle the adClicked message if you want to perform an action when a user clicks on an ad.
touchStart: Sent when a user touches a control in a mobile application
Mobile Messages
12
Calculator App
13. If you wish to learn more… Visit LiveCode
Congrats on learning:
Messages
Calculator App
13