Mouse

Events

There are individual events for the up and down events for left, right, and middle mouse buttons: onLeftDown, onLeftUp, onRightDown, onRightUp, onMiddleDown, onMiddleUp.

Mouse.onLeftDown.Connect(() => {
    print("Left button down");
});

Mouse.onLeftUp.Connect(() => {
    print("Left button up");
});

Polling

The state of each button can also be checked with the IsLeftButtonDown (et. al.) methods.

if (Mouse.IsLeftButtonDown()) {
    print("Left button down");
}

if (Mouse.IsRightButtonDown()) {
    print("Right button down");
}

if (Mouse.IsMiddleButtonDown()) {
    print("Middle button down");
}

Movement

Events

The Moved event fires when the mouse is moved. The onScrolled event fires when the scroll wheel is moved.

Polling

Use the position field and GetDelta method to retrieve information about mouse movement.

Last updated