Class: Tea::Mouse::Scroll

Inherits:
Object
  • Object
show all
Defined in:
lib/tea/m_event_mouse.rb

Overview

Event generated when the mouse wheel is scrolled.

x, y

coordinates of the mouse cursor.

delta

1 when scrolling down, -1 when scrolling up.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sdl_event) ⇒ Scroll

Returns a new instance of Scroll.



72
73
74
75
76
77
78
79
80
81
# File 'lib/tea/m_event_mouse.rb', line 72

def initialize(sdl_event)
  @x = sdl_event.x
  @y = sdl_event.y
  case sdl_event.button
  when Event::BUTTON_WHEELDOWN_ then @delta = 1
  when Event::BUTTON_WHEELUP_   then @delta = -1
  else
    raise Tea::Error, "Tea::Mouse::Scroll given an unexpected event: #{sdl_event.inspect}", caller
  end
end

Instance Attribute Details

#deltaObject (readonly)

Returns the value of attribute delta.



71
72
73
# File 'lib/tea/m_event_mouse.rb', line 71

def delta
  @delta
end

#xObject (readonly)

Returns the value of attribute x.



71
72
73
# File 'lib/tea/m_event_mouse.rb', line 71

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



71
72
73
# File 'lib/tea/m_event_mouse.rb', line 71

def y
  @y
end