Module: Tea::Mouse
- Defined in:
- lib/tea/m_event_app.rb,
lib/tea/m_event_mouse.rb
Defined Under Namespace
Classes: Down, Gained, Lost, Move, Scroll, Up
Constant Summary collapse
- LEFT =
Mouse button constants for mouse events.
:LEFT
- MIDDLE =
:MIDDLE
- RIGHT =
:RIGHT
Class Method Summary collapse
-
.in_app? ⇒ Boolean
Returns true if the mouse is in the screen window.
-
.left? ⇒ Boolean
Returns true if the left mouse button is down.
-
.middle? ⇒ Boolean
Returns true if the middle mouse button is down.
-
.right? ⇒ Boolean
Returns true if the right mouse button is down.
-
.update_state(tea_event) ⇒ Object
Update the mouse state, so that Mouse.x, Mouse.y, Mouse.left?, Mouse.middle? and Mouse.right? return recent data.
-
.x ⇒ Object
Report the x position of the mouse in the screen window.
-
.y ⇒ Object
Report the y position of the mouse in the screen window.
Class Method Details
.in_app? ⇒ Boolean
Returns true if the mouse is in the screen window
124 125 126 |
# File 'lib/tea/m_event_mouse.rb', line 124 def Mouse.in_app? @in_app end |
.left? ⇒ Boolean
Returns true if the left mouse button is down. Updated when Event.get is called.
107 108 109 |
# File 'lib/tea/m_event_mouse.rb', line 107 def Mouse.left? @left end |
.middle? ⇒ Boolean
Returns true if the middle mouse button is down. Updated when Event.get is called.
113 114 115 |
# File 'lib/tea/m_event_mouse.rb', line 113 def Mouse.middle? @middle end |
.right? ⇒ Boolean
Returns true if the right mouse button is down. Updated when Event.get is called.
119 120 121 |
# File 'lib/tea/m_event_mouse.rb', line 119 def Mouse.right? @right end |
.update_state(tea_event) ⇒ Object
Update the mouse state, so that Mouse.x, Mouse.y, Mouse.left?, Mouse.middle? and Mouse.right? return recent data.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/tea/m_event_mouse.rb', line 130 def Mouse.update_state(tea_event) case tea_event when Move @x = tea_event.x @y = tea_event.y when Down case tea_event. when LEFT then @left = true when MIDDLE then @middle = true when RIGHT then @right = true end when Up case tea_event. when LEFT then @left = false when MIDDLE then @middle = false when RIGHT then @right = false end when Lost @in_app = false when Gained @in_app = true end end |
.x ⇒ Object
Report the x position of the mouse in the screen window. Updated when Event.get is called.
95 96 97 |
# File 'lib/tea/m_event_mouse.rb', line 95 def Mouse.x @x end |
.y ⇒ Object
Report the y position of the mouse in the screen window. Updated when Event.get is called.
101 102 103 |
# File 'lib/tea/m_event_mouse.rb', line 101 def Mouse.y @y end |