Skip to main content

Mouse Event

MouseDown

Definition: MouseDown Int ( Float, Float )

Triggered when a mouse button is pressed.

MouseUp

Definition: MouseUp Int ( Float, Float )

Triggered when a mouse button is released.

The parameters of MouseDown and MouseUp represent button and position.

  • button indicates which mouse button was pressed. For example, 0 represents the left mouse button, and 2 represents the right mouse button. More values can be found in MDN.

  • position represents the virtual coordinate of the mouse.

tip

Current position of the mouse could also be got from globalData.mousePos.

MouseWheel

Definition: MouseWheel Int

The parameter represents the vertical scroll amount delta, which corresponds to the deltaY property in WheelEvent.

note

Users can use judgeMouseRect in Messenger.Coordinate.Coordinates to check whether the mouse is in a rectangle.

The mouse coordinate is not transformed through the camera, so it is using the default UI camera starting from (0, 0) to (virtWidth, virtHeight).

To judge whether the mouse position is in a rectangle defined in a non-UI camera, users could use judgeMouseRectWithCamera to check.

To judge whether mouse is within a circle, use judgeMouseCircle. Users could also write there own judge functions.

note

Users can use globalData.pressedMouseButtons to get the current pressed mouses.