User Guide
Chapter 15380
Finding mouse pointer locations with Lingo
Determining where the mouse pointer is on the Stage is a common need in Director.
To determine the mouse pointer’s horizontal and vertical positions:
• Use the mouseH() and mouseV() functions. See mouseH and mouseV in the Lingo Dictionary.
The
mouseV() function returns the distance, in pixels, between the mouse pointer and the upper
left corner of the Stage. The
mouseH() function returns the distance, in pixels, between the mouse
pointer and the upper left corner of the Stage.
The statements
put the mouseH and put the mouseV display the mouse pointer’s location in
the Message window.
For example, this handler directs the Message window to display the distance (in pixels) between
the pointer and the upper left corner of the Stage:
on exitFrame
put the mouseH
put the mouseV
go to the frame
end
Checking keys with Lingo
Lingo can detect the last key that the user pressed. See individual properties and functions in the
Lingo Dictionary.
• To obtain the ANSI value of the last key that was pressed, use the key() function.
• To obtain the keyboard’s numerical (or ASCII) value for the last key pressed, use the
keyCode() function.
A common place for using key and keyCode is in an on keyDown handler, which instructs
Lingo to check the value of
key only when a key is actually pressed. For example, the following
handler in a frame script sends the playhead to the next marker whenever the user presses Enter
(Windows) or Return (Macintosh):
on keyDown
if the key = RETURN then go to marker (1)
end
Equivalent cross-platform keys
Because of inherent differences between Windows and Macintosh keyboards, keys on Windows
and Macintosh computers don’t always correspond directly.
This discrepancy can create confusion because Lingo often uses the same term to refer to
corresponding keys on Windows and Macintosh computers, even though the key’s name differs
on the two platforms.
The following table lists Lingo elements that refer to specific keys and the keys they represent on
each platform.
Lingo term Windows key Macintosh key
RETURN Enter Return
commandDown Control Command