ExRatatui.Event.Mouse (ExRatatui v0.7.1)

Copy Markdown View Source

A mouse event.

Fields

  • :kind - the type of mouse event: "down", "up", "drag", "moved", "scroll_up", "scroll_down", "scroll_left", "scroll_right"
  • :button - the mouse button: "left", "right", "middle", or "" (empty for scroll and move events)
  • :x - column position (0-based)
  • :y - row position (0-based)
  • :modifiers - list of active modifiers: "shift", "ctrl", "alt", "super", "hyper", "meta"

Examples

iex> %ExRatatui.Event.Mouse{kind: "down", button: "left", x: 5, y: 10}
%ExRatatui.Event.Mouse{kind: "down", button: "left", x: 5, y: 10, modifiers: []}

Pattern matching on events:

# Match a left click
%Event.Mouse{kind: "down", button: "left", x: x, y: y}

# Match scroll up
%Event.Mouse{kind: "scroll_up"}

Summary

Types

t()

@type t() :: %ExRatatui.Event.Mouse{
  button: String.t(),
  kind: String.t(),
  modifiers: [String.t()],
  x: non_neg_integer(),
  y: non_neg_integer()
}