paint/event

This module contains events that can be triggered when building interactive applications.

See paint/canvas and the canvas.interact function for a practical example of how this is used.

Types

pub type Event {
  Tick(Float)
  KeyboardPressed(Key)
  KeyboardRelased(Key)
  MouseMoved(Float, Float)
  MousePressed(MouseButton)
  MouseReleased(MouseButton)
}

Constructors

  • Tick(Float)

    Triggered before drawing. Contains the number of milliseconds elapsed.

  • KeyboardPressed(Key)

    Triggered when a key is pressed

  • KeyboardRelased(Key)

    Triggered when a key is released

  • MouseMoved(Float, Float)

    Triggered when the mouse is moved. Contains the x and y value for the mouse position.

  • MousePressed(MouseButton)

    Triggered when a mouse button is pressed

  • MouseReleased(MouseButton)

    Triggered when a mouse button is released.

    Note, on the web you might encounter issues where the release event for the right mouse button is not triggered because of the context menu.

pub type Key {
  KeyLeftArrow
  KeyRightArrow
  KeyUpArrow
  KeyDownArrow
  KeySpace
  KeyW
  KeyA
  KeyS
  KeyD
  KeyZ
  KeyX
  KeyC
  KeyEnter
  KeyEscape
  KeyBackspace
}

Constructors

  • KeyLeftArrow
  • KeyRightArrow
  • KeyUpArrow
  • KeyDownArrow
  • KeySpace
  • KeyW
  • KeyA
  • KeyS
  • KeyD
  • KeyZ
  • KeyX
  • KeyC
  • KeyEnter
  • KeyEscape
  • KeyBackspace
pub type MouseButton {
  MouseButtonLeft
  MouseButtonRight
  MouseButtonMiddle
}

Constructors

  • MouseButtonLeft
  • MouseButtonRight
  • MouseButtonMiddle

    The scroll wheel button

Search Document