MouseButton

View source

Defines the numeric engine codes for mouse buttons.

MouseButton.Left (0) is the primary button, MouseButton.Wheel (1) is the wheel or middle button, and MouseButton.Right (2) is the secondary button. The auxiliary navigation buttons are MouseButton.Back (3) and MouseButton.Forward (4); MouseButton.Dpi (5) is a DPI button, and MouseButton.Unidentified (7) represents an unknown or unsupported button value.

Use these values with MouseButtons and its inherited button-state queries.

Examples

import { MouseButton, MouseButtons } from '@wimaengine/mouse'

function handleMouse(world) {
  const buttons = world.getResource(MouseButtons)

  if (buttons.justPressed(MouseButton.Left)) {
    console.log('primary button pressed')
  }
}

Variants