Class: Tea::Mouse::Down

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

Overview

Event generated when a mouse button is held down.

x, y

coordinates of the mouse cursor

button

the mouse button that is down: :left, :middle or :right

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sdl_event) ⇒ Down

Returns a new instance of Down.



37
38
39
40
41
42
43
44
45
# File 'lib/tea/m_event_mouse.rb', line 37

def initialize(sdl_event)
  @x = sdl_event.x
  @y = sdl_event.y
  case sdl_event.button
  when SDL::Mouse::BUTTON_LEFT   then @button = Mouse::LEFT
  when SDL::Mouse::BUTTON_MIDDLE then @button = Mouse::MIDDLE
  when SDL::Mouse::BUTTON_RIGHT  then @button = Mouse::RIGHT
  end
end

Instance Attribute Details

#buttonObject (readonly)

Returns the value of attribute button.



36
37
38
# File 'lib/tea/m_event_mouse.rb', line 36

def button
  @button
end

#xObject (readonly)

Returns the value of attribute x.



36
37
38
# File 'lib/tea/m_event_mouse.rb', line 36

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



36
37
38
# File 'lib/tea/m_event_mouse.rb', line 36

def y
  @y
end