Class: Vedeu::Input::Mouse Private
- Inherits:
-
Object
- Object
- Vedeu::Input::Mouse
- Defined in:
- lib/vedeu/input/mouse.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Rudimentary support for mouse interactions.
Instance Attribute Summary collapse
- #input ⇒ String readonly protected private
Class Method Summary collapse
-
.click(input) ⇒ void
private
Trigger an event depending on which button was pressed.
Instance Method Summary collapse
- #button ⇒ Fixnum private private
-
#click ⇒ void
private
Trigger an event depending on which button was pressed.
-
#initialize(input) ⇒ Vedeu::Input::Mouse
constructor
private
Returns a new instance of Vedeu::Input::Mouse.
-
#left_click? ⇒ Boolean
private
private
Returns a boolean indicating the mouse interaction was recognised as a left click.
- #mouse ⇒ Array<Fixnum> private private
-
#wheel_down? ⇒ Boolean
private
private
Returns a boolean indicating the mouse interaction was recognised as the scroll wheel moving down.
-
#wheel_up? ⇒ Boolean
private
private
Returns a boolean indicating the mouse interaction was recognised as the scroll wheel moving up.
- #x ⇒ Fixnum private private
- #y ⇒ Fixnum private private
Constructor Details
#initialize(input) ⇒ Vedeu::Input::Mouse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Input::Mouse.
25 26 27 |
# File 'lib/vedeu/input/mouse.rb', line 25 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ String (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/vedeu/input/mouse.rb', line 61 def input @input end |
Class Method Details
.click(input) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Trigger an event depending on which button was pressed.
17 18 19 |
# File 'lib/vedeu/input/mouse.rb', line 17 def self.click(input) new(input).click end |
Instance Method Details
#button ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 |
# File 'lib/vedeu/input/mouse.rb', line 66 def mouse[0] end |
#click ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Trigger an event depending on which button was pressed.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vedeu/input/mouse.rb', line 32 def click Vedeu.log(type: :input, message: "Mouse pressed: '#{}' " \ "(x: #{x}, y: #{y})") Vedeu.trigger(:_mouse_event_, input) if left_click? Vedeu.trigger(:_cursor_reposition_, Vedeu.focus, y, x) elsif wheel_up? Vedeu.trigger(:_cursor_up_, Vedeu.focus) elsif wheel_down? Vedeu.trigger(:_cursor_down_, Vedeu.focus) else Vedeu.log(type: :input, message: 'Vedeu does not support mouse button ' \ "'#{}' yet.") false end end |
#left_click? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the mouse interaction was recognised as a left click.
74 75 76 |
# File 'lib/vedeu/input/mouse.rb', line 74 def left_click? == 0 end |
#mouse ⇒ Array<Fixnum> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/vedeu/input/mouse.rb', line 79 def mouse @_input ||= input.chars[3..-1].map { |character| character.ord - 32 } end |
#wheel_down? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the mouse interaction was recognised as the scroll wheel moving down.
95 96 97 |
# File 'lib/vedeu/input/mouse.rb', line 95 def wheel_down? == 65 end |
#wheel_up? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the mouse interaction was recognised as the scroll wheel moving up.
87 88 89 |
# File 'lib/vedeu/input/mouse.rb', line 87 def wheel_up? == 64 end |
#x ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
100 101 102 |
# File 'lib/vedeu/input/mouse.rb', line 100 def x mouse[1] end |
#y ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
105 106 107 |
# File 'lib/vedeu/input/mouse.rb', line 105 def y mouse[2] end |