[ type ] MouseEvent

Description:

Mouse event received by the onMouseEvents() handler callback.

Type: Object

Properties:

Name Type Description

target

object

The component that triggered the event.

type

string

One of click, down, up, enter, leave.

[button]

number

Button number. One of MouseButton enum values. Present when type is click, down, or up.

[clicks]

number

Number of times the button was clicked. Present only when applicable, such as when type is click.

[modifiers]

number

Keyboard modifiers (bitmask or flags).

[alt]

boolean

Indicates if ALT key was pressed.

[shift]

boolean

Indicates if SHIFT key was pressed.

[ctrl]

boolean

Indicates if CTRL key was pressed.

[x]

number

Mouse X position relative to the component. Present when applicable.

[y]

number

Mouse Y position relative to the component. Present when applicable.

[screenX]

number

Mouse X position relative to the primary screen. Present when applicable.

[screenY]

number

Mouse Y position relative to the primary screen. Present when applicable.

Examples:

Detecting a single mouse button left click

const label = new Label("Click Me").addTo(panel).onMouseEvents(e=>{
    if(e.type === "click" && e.button === MouseButton.Left && e.clicks === 1)
    {
    		console.log("User clicked this label: " + e.target.text());
    }
});

Also See: