struct Termisu::Event::Mouse

Overview

Mouse input event.

Contains mouse position, button state, and modifiers. Supports all mouse protocols (X10, Normal, SGR, URXVT).

Example:

event = termisu.poll_event
if event.is_a?(Termisu::Event::Mouse)
  case event.button
  when .left?
    puts "Left click at #{event.x},#{event.y}"
  when .wheel_up?
    puts "Scroll up"
  when .release?
    puts "Button released"
  end
end

Defined in:

termisu/event/mouse.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(x : Int32, y : Int32, button : MouseButton, modifiers : Input::Modifier = Input::Modifier::None, motion : Bool = false) #

[View source]

Instance Method Detail

def alt? : Bool #

Returns true if Alt modifier was held.


[View source]
def button : MouseButton #

Mouse button that triggered the event.


[View source]
def ctrl? : Bool #

Returns true if Ctrl modifier was held.


[View source]
def meta? : Bool #

Returns true if Meta/Super/Windows modifier was held.


[View source]
def modifiers : Input::Modifier #

Modifier keys held during the mouse event.


[View source]
def motion? : Bool #

Whether this is a motion event (mouse moved while button held).


[View source]
def press? : Bool #

Returns true if this is a button press event.


[View source]
def shift? : Bool #

Returns true if Shift modifier was held.


[View source]
def wheel? : Bool #

Returns true if this is a wheel scroll event.


[View source]
def x : Int32 #

X coordinate (column, 1-based).


[View source]
def y : Int32 #

Y coordinate (row, 1-based).


[View source]