Class: Rubydraw::Events::MousePressed

Inherits:
Event show all
Defined in:
lib/rubydraw/events.rb

Overview

Created when a mouse button is down. Note: this event is used for any mouse button.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Event

#event?, matches?, wants_to_match?

Constructor Details

#initialize(position, button) ⇒ MousePressed

Creates a new MousePressed event, specifying where (the position) it happened and what button was pressed.



157
158
159
# File 'lib/rubydraw/events.rb', line 157

def initialize(position, button)
  @position, @button = position, button
end

Instance Attribute Details

#buttonObject (readonly)

Returns the value of attribute button.



153
154
155
# File 'lib/rubydraw/events.rb', line 153

def button
  @button
end

#positionObject (readonly)

Returns the value of attribute position.



153
154
155
# File 'lib/rubydraw/events.rb', line 153

def position
  @position
end

Class Method Details

.from_sdl_event(sdl_event) ⇒ Object



145
146
147
# File 'lib/rubydraw/events.rb', line 145

def self.from_sdl_event(sdl_event)
  self.new(Point[sdl_event.x, sdl_event.y], sdl_event.button)
end

.matching_sdl_typeObject



149
150
151
# File 'lib/rubydraw/events.rb', line 149

def self.matching_sdl_type
  SDL::MOUSEBUTTONDOWN
end