Tuix.Event.Mouse (tuix v0.1.5)

Copy Markdown View Source

A mouse event.

kind is one of:

  • :press / :release - a button went down / up
  • :click - synthesized by the runtime after a :release that lands on the same target its :press hit; releasing over a different target cancels the click (dragging within the target does not)
  • :drag - the pointer moved while a button was held
  • :scroll_up / :scroll_down - the wheel turned

button is :left, :middle, or :right (nil for wheel events and releases that do not report a button; always set on :click). x and y are 0-based cell coordinates (a :click carries the release coordinates).

target is the id of the innermost focusable element under the pointer (nil when none), stamped by the runtime so apps can pattern match on it:

def handle_event(%Mouse{kind: :click, target: :sidebar}, app), do: ...

Summary

Types

button()

@type button() :: :left | :middle | :right | nil

kind()

@type kind() :: :press | :release | :click | :drag | :scroll_up | :scroll_down

t()

@type t() :: %Tuix.Event.Mouse{
  alt: boolean(),
  button: button(),
  ctrl: boolean(),
  kind: kind(),
  shift: boolean(),
  target: term() | nil,
  x: non_neg_integer(),
  y: non_neg_integer()
}