Class: Rubygame::MouseDownEvent
Overview
Indicates that a mouse button was pressed.
This event has these attributes:
- string
-
string indicating the button that was pressed (“left”,“middle”, or “right”).
- pos
-
the position of the mouse cursor when the button was pressed, in the form [x,y].
- button
-
the mouse button that was pressed; one of these constants in module Rubygame (or the corresponding button number):
- MOUSE_LEFT
-
1; left mouse button
- MOUSE_MIDDLE
-
2; middle mouse button
- MOUSE_RIGHT
-
3; right mouse button
Instance Attribute Summary collapse
-
#button ⇒ Object
Returns the value of attribute button.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#string ⇒ Object
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(pos, button) ⇒ MouseDownEvent
constructor
A new instance of MouseDownEvent.
Constructor Details
#initialize(pos, button) ⇒ MouseDownEvent
Returns a new instance of MouseDownEvent.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/rubygame/event.rb', line 275 def initialize(pos,) @pos = pos if .kind_of? Integer @button = @string = Rubygame::Mouse::MOUSE2STR[] #a string or nil elsif key.kind_of? String @button = Rubygame::Mouse::STR2MOUSE[key] if @button != nil @string = else raise(ArgumentError,"First argument of MouseDownEvent.new() must be an Integer Mouse button indentifier (like MOUSE_LEFT) or a String (like \"left\"). Got %s (%s)"%[,.class]) end end end |
Instance Attribute Details
#button ⇒ Object
Returns the value of attribute button.
274 275 276 |
# File 'lib/rubygame/event.rb', line 274 def @button end |
#pos ⇒ Object
Returns the value of attribute pos.
274 275 276 |
# File 'lib/rubygame/event.rb', line 274 def pos @pos end |
#string ⇒ Object
Returns the value of attribute string.
274 275 276 |
# File 'lib/rubygame/event.rb', line 274 def string @string end |