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()
The
function returns the distance, in pixels, between the mouse pointer and the upper
mouseV()
left corner of the Stage. The
pointer and the upper left corner of the Stage.
The statements
put the mouseH
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
•
To obtain the keyboard's numerical (or ASCII) value for the last key pressed, use the
function.
keyCode()
A common place for using
Lingo to check the value of
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
RETURN
commandDown
380
Chapter 15
and
functions. See
mouseV()
function returns the distance, in pixels, between the mouse
mouseH()
and
put the mouseV
and
key
keyCode
only when a key is actually pressed. For example, the following
key
Windows key
Enter
Control
and
mouseH
mouseV
display the mouse pointer's location in
key()
is in an
handler, which instructs
on keyDown
Macintosh key
Return
Command
in the Lingo Dictionary.
function.