Class: SDC::Event
- Inherits:
-
Object
- Object
- SDC::Event
- Defined in:
- engine_docs/automatic_doc_Event.rb,
lib/core/Event.rb,
engine_docs/automatic_doc_Event.rb
Overview
Event container class
Instance Attribute Summary collapse
-
#key_code ⇒ Integer
Key value of the event if it is a key press.
-
#mouse_button_code ⇒ Integer
Mouse button value of the event if it is a mouse button press.
-
#mouse_button_x ⇒ Integer
Mouse x coordinate in pixels, relative to the owning window, when a button was pressed.
-
#mouse_button_y ⇒ Integer
Mouse y coordinate in pixels, relative to the owning window, when a button was pressed.
-
#mouse_move_x ⇒ Integer
Mouse x coordinate in pixels, relative to the owning window, when the mouse was moved.
-
#mouse_move_y ⇒ Integer
Mouse y coordinate in pixels, relative to the owning window, when the mouse was moved.
-
#mouse_scroll_delta ⇒ Float
Mouse wheel scrolling distance.
-
#mouse_scroll_wheel ⇒ Integer
Mouse wheel scrolled if a mouse scrolling event was triggered (0 for vertical, 1 for horizontal).
-
#mouse_scroll_x ⇒ Integer
Mouse x motion in pixels, relative to the owning window, when a wheel was scrolled.
-
#mouse_scroll_y ⇒ Integer
Mouse y motion in pixels, relative to the owning window, when a wheel was scrolled.
-
#text_unicode ⇒ String
Inputted text if an input happened.
-
#type ⇒ Integer
Type of the event.
Instance Method Summary collapse
- #has_type?(event_type) ⇒ Boolean
-
#initialize ⇒ Event
constructor
Creates an empty event object.
-
#key_alt? ⇒ Boolean
Returns true if an alt key is pressed.
-
#key_control? ⇒ Boolean
Returns true if a ctrl key is pressed.
- #key_pressed?(key) ⇒ Boolean
-
#key_shift? ⇒ Boolean
Returns true if a shift key is pressed.
-
#key_system? ⇒ Boolean
Returns true if a system key is pressed.
- #mouse_button_pressed?(button) ⇒ Boolean
- #mouse_coordinates ⇒ Object
- #mouse_left_click? ⇒ Boolean
- #mouse_right_click? ⇒ Boolean
- #mouse_scrolled_down? ⇒ Boolean
- #mouse_scrolled_up? ⇒ Boolean
- #new_mouse_coordinates ⇒ Object
- #text_char ⇒ Object
Constructor Details
#initialize ⇒ Event
Creates an empty event object
|
# File 'engine_docs/automatic_doc_Event.rb', line 9
|
Instance Attribute Details
#key_code ⇒ Integer
Key value of the event if it is a key press
|
# File 'engine_docs/automatic_doc_Event.rb', line 19
|
#mouse_button_code ⇒ Integer
Mouse button value of the event if it is a mouse button press
|
# File 'engine_docs/automatic_doc_Event.rb', line 44
|
#mouse_button_x ⇒ Integer
Mouse x coordinate in pixels, relative to the owning window, when a button was pressed
|
# File 'engine_docs/automatic_doc_Event.rb', line 49
|
#mouse_button_y ⇒ Integer
Mouse y coordinate in pixels, relative to the owning window, when a button was pressed
|
# File 'engine_docs/automatic_doc_Event.rb', line 53
|
#mouse_move_x ⇒ Integer
Mouse x coordinate in pixels, relative to the owning window, when the mouse was moved
|
# File 'engine_docs/automatic_doc_Event.rb', line 57
|
#mouse_move_y ⇒ Integer
Mouse y coordinate in pixels, relative to the owning window, when the mouse was moved
|
# File 'engine_docs/automatic_doc_Event.rb', line 61
|
#mouse_scroll_delta ⇒ Float
Mouse wheel scrolling distance
|
# File 'engine_docs/automatic_doc_Event.rb', line 69
|
#mouse_scroll_wheel ⇒ Integer
Mouse wheel scrolled if a mouse scrolling event was triggered (0 for vertical, 1 for horizontal)
|
# File 'engine_docs/automatic_doc_Event.rb', line 65
|
#mouse_scroll_x ⇒ Integer
Mouse x motion in pixels, relative to the owning window, when a wheel was scrolled
|
# File 'engine_docs/automatic_doc_Event.rb', line 73
|
#mouse_scroll_y ⇒ Integer
Mouse y motion in pixels, relative to the owning window, when a wheel was scrolled
|
# File 'engine_docs/automatic_doc_Event.rb', line 77
|
#text_unicode ⇒ String
Inputted text if an input happened
|
# File 'engine_docs/automatic_doc_Event.rb', line 81
|
#type ⇒ Integer
Type of the event
|
# File 'engine_docs/automatic_doc_Event.rb', line 14
|
Instance Method Details
#has_type?(event_type) ⇒ Boolean
7 8 9 |
# File 'lib/core/Event.rb', line 7 def has_type?(event_type) return self.type == SDC::EventType.const_get(event_type) end |
#key_alt? ⇒ Boolean
Returns true if an alt key is pressed
|
# File 'engine_docs/automatic_doc_Event.rb', line 24
|
#key_control? ⇒ Boolean
Returns true if a ctrl key is pressed
|
# File 'engine_docs/automatic_doc_Event.rb', line 29
|
#key_pressed?(key) ⇒ Boolean
11 12 13 |
# File 'lib/core/Event.rb', line 11 def key_pressed?(key) return self.key_code == SDC.key(key) end |
#key_shift? ⇒ Boolean
Returns true if a shift key is pressed
|
# File 'engine_docs/automatic_doc_Event.rb', line 34
|
#key_system? ⇒ Boolean
Returns true if a system key is pressed
|
# File 'engine_docs/automatic_doc_Event.rb', line 39
|
#mouse_button_pressed?(button) ⇒ Boolean
15 16 17 |
# File 'lib/core/Event.rb', line 15 def () return self. == SDC.() end |
#mouse_coordinates ⇒ Object
35 36 37 |
# File 'lib/core/Event.rb', line 35 def mouse_coordinates return SDC::Coordinates.new(self..to_f, self..to_f) end |
#mouse_left_click? ⇒ Boolean
19 20 21 |
# File 'lib/core/Event.rb', line 19 def mouse_left_click? return (:Left) end |
#mouse_right_click? ⇒ Boolean
23 24 25 |
# File 'lib/core/Event.rb', line 23 def mouse_right_click? return (:Right) end |
#mouse_scrolled_down? ⇒ Boolean
27 28 29 |
# File 'lib/core/Event.rb', line 27 def mouse_scrolled_down? return self.mouse_scroll_wheel == SDC::EventMouse::VerticalWheel && self.mouse_scroll_delta < 0.0 end |
#mouse_scrolled_up? ⇒ Boolean
31 32 33 |
# File 'lib/core/Event.rb', line 31 def mouse_scrolled_up? return self.mouse_scroll_wheel == SDC::EventMouse::VerticalWheel && self.mouse_scroll_delta > 0.0 end |
#new_mouse_coordinates ⇒ Object
39 40 41 |
# File 'lib/core/Event.rb', line 39 def new_mouse_coordinates return SDC::Coordinates.new(self.mouse_move_x.to_f, self.mouse_move_y.to_f) end |
#text_char ⇒ Object
43 44 45 |
# File 'lib/core/Event.rb', line 43 def text_char return self.text_unicode.chr("UTF-8") end |