A newer version of Max is available. Click here to access the latest version of this document.

mousestate

Report the status and location of the mouse

Description

mousestate provides button-status and cursor-position information about the mouse/cursor when the cursor is positioned within a Max patcher window. The mouse button is sampled every 50ms. The mouse position is sampled every input bang.

Arguments

None.

Messages

bang Sends out the current horizontal and vertical coordinates of the location of the mouse, as well as the change in location since the last output.
nopoll Undoes a poll message, reverting mousestate to its normal condition of waiting for a bang before reporting.
mode coordinate-reference (0 through 2) [int]
The word mode, followed by a long value specifices the type of reference to use for the mouse coordinates from the second and third outlets. A value of 0 specifies to use screen-relative coordinates where 0,0 is the top left corner of the primary display. A value of 1 specifies patcher-relative coordinates where 0,0 is the top left corner of the content area of the mousestate object's patcher. A value of 2 specifies front-most patcher relative coordinates where 0,0 is the top left corner of the content area of the top patcher window.
poll Causes mousestate to send out the mouse location, and the change in mouse location, whenever the mouse is moved, as well as when a bang is received.
reset Resets the 0,0 point to its default setting, in the upper left corner of the screen.
zero Resets the point mousestate considers as the 0,0 point from which to measure the mouse location. The current location of the mouse is considered the new 0,0 point.

Information for box attributes common to all objects

Output

int: mousestate must have received at least one bang or poll message in its inlet before any output is sent out.

Out left outlet: Each time the mouse button is pressed, 1 is sent out. Each time the mouse button is released, 0 is sent out.

Out 2nd outlet: The horizontal location of the mouse, measured in terms of the number of pixels the mouse is to the right of the 0 point.

Out 3rd outlet: The vertical location of the mouse, measured in terms of the number of pixels the mouse is below the 0 point.

Out 4th outlet: The change in horizontal location of the mouse, since the last time the mouse location was reported.

Out right outlet: The change in vertical location of the mouse, since the last time the mouse location was reported.

Examples

The mouse can provide continuous or discrete values

See Also

Name Description
mousefilter Pass numbers only when the mouse button is up
Max Basic Tutorial 8: Keyboard and Mouse Input Max Basic Tutorial 8: Keyboard and Mouse Input