Lingo Dictionary > L-N > on mouseDown (event handler) |  |

on mouseDown (event handler)

Syntax

    on mouseDown
    	statement(s)
    end

Description

System message and event handler; contains statements that run when the mouse button is pressed.

When the mouse button is pressed, Lingo searches the following locations, in order, for an `on` `mouseDown` handler: primary event handler, sprite script, cast member script, frame script, and movie script. Lingo stops searching when it reaches the first location that has an `on mouseDown` handler, unless the handler includes the `pass` command to explicitly pass the `mouseDown` message on to the next location.

To have the same response throughout the movie when pressing the mouse button, set `mouseDownScript` or put a mouseDown handler in a Movie script.

The `on mouseDown` event handler is a good place to put Lingo that flashes images, triggers sound effects, or makes sprites move when the user presses the mouse button.

Where you place an `on mouseDown` handler can affect when it runs.

| To apply the handler to a specific sprite, put it in a sprite script.
| To apply the handler to a cast member in general, put it in a cast member script.
| To apply the handler to an entire frame, put it in a frame script.
| To apply the handler throughout the entire movie, put it in a movie script.

You can override an `on mouseDown` handler by placing an alternative `on mouseDown` handler in a location that Lingo checks before it gets to the handler you want to override. For example, you can override an `on mouseDown` handler assigned to a cast member by placing an `on mouseDown` handler in a sprite script.

If used in a behavior, this event is passed the sprite script or frame script reference `me`.

Example

This handler checks whether the user clicks anywhere on the Stage and sends the playback head to another frame if a click occurs:

    on mouseDown
    	if the clickOn = 0 then go to frame "AddSum"
    end

Example

This handler, assigned to a sprite script, plays a sound when the sprite is clicked:

    on mouseDown
    	puppetSound "Crickets"
    end

See also

`clickOn`, `mouseDownScript`, `mouseUpScript`