Class: Rubydraw::Events::MouseMove

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

Overview

Created when the mouse is moved.

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, relative_position) ⇒ MouseMove

Create a new MouseMove event with the new mouse position.

x and y: The new position of the cursor.

relative_x and relative_y: The relative movement of the cursor since the lasttick.



199
200
201
# File 'lib/rubydraw/events.rb', line 199

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

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



192
193
194
# File 'lib/rubydraw/events.rb', line 192

def position
  @position
end

#relative_positionObject (readonly)

Returns the value of attribute relative_position.



192
193
194
# File 'lib/rubydraw/events.rb', line 192

def relative_position
  @relative_position
end

Class Method Details

.from_sdl_event(sdl_event) ⇒ Object



184
185
186
# File 'lib/rubydraw/events.rb', line 184

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

.matching_sdl_typeObject



188
189
190
# File 'lib/rubydraw/events.rb', line 188

def self.matching_sdl_type
  SDL::MOUSEMOTION
end

Instance Method Details

#xObject

Returns the new x positon of the mouse.



204
205
206
# File 'lib/rubydraw/events.rb', line 204

def x
  @position.x
end

#yObject

Returns the new y mouse positon.



209
210
211
# File 'lib/rubydraw/events.rb', line 209

def y
  @position.y
end