Class: Cura::Event::MouseButton
- Defined in:
- lib/cura/event/mouse_button.rb
Overview
Dispatched when a mouse’s button state changes.
Constant Summary collapse
- VALID_NAMES =
[:left, :middle, :right]
- VALID_STATES =
[:up, :down, :click, :double_click]
Instance Attribute Summary
Attributes inherited from Mouse
Attributes inherited from Base
Instance Method Summary collapse
-
#click? ⇒ Boolean
Get whether the mouse button state is double_click.
-
#down? ⇒ Boolean
Get whether the mouse button state is down.
-
#initialize(attributes = {}) ⇒ MouseButton
constructor
A new instance of MouseButton.
-
#left? ⇒ Boolean
Get whether the mouse button state occurred the left button.
-
#middle? ⇒ Boolean
Get whether the mouse button state occurred the middle button.
-
#name ⇒ Symbol
Get the mouse button name.
-
#name=(value) ⇒ Symbol
Set the mouse button name.
-
#right? ⇒ Boolean
Get whether the mouse button state occurred the right button.
-
#state ⇒ Symbol
Get the mouse button state.
-
#state=(value) ⇒ Symbol
Set the mouse button state.
-
#up? ⇒ Boolean
Get whether the mouse button state is up.
Methods inherited from Base
#==, #dispatch, inherited, name, #to_h
Methods included from Attributes::HasAttributes
Constructor Details
#initialize(attributes = {}) ⇒ MouseButton
Returns a new instance of MouseButton.
10 11 12 13 14 15 |
# File 'lib/cura/event/mouse_button.rb', line 10 def initialize(attributes={}) super # raise ArgumentError, "name must be set" if @name.nil? # TODO: Termbox doesn't support which button was released yet raise ArgumentError, "state must be set" if @state.nil? end |
Instance Method Details
#click? ⇒ Boolean
Get whether the mouse button state is double_click.
|
# File 'lib/cura/event/mouse_button.rb', line 74
|
#down? ⇒ Boolean
Get whether the mouse button state is down.
|
# File 'lib/cura/event/mouse_button.rb', line 69
|
#left? ⇒ Boolean
Get whether the mouse button state occurred the left button.
|
# File 'lib/cura/event/mouse_button.rb', line 45
|
#middle? ⇒ Boolean
Get whether the mouse button state occurred the middle button.
|
# File 'lib/cura/event/mouse_button.rb', line 50
|
#name ⇒ Symbol
Get the mouse button name. Will return ‘:left`, `:middle`, or `:right`.
|
# File 'lib/cura/event/mouse_button.rb', line 31
|
#name=(value) ⇒ Symbol
Set the mouse button name.
43 |
# File 'lib/cura/event/mouse_button.rb', line 43 attribute(:name) { |value| validate_list(value, VALID_NAMES) } |
#right? ⇒ Boolean
Get whether the mouse button state occurred the right button.
60 61 62 |
# File 'lib/cura/event/mouse_button.rb', line 60 VALID_NAMES.each do |name| define_method("#{name}?") { @name == name } end |
#state ⇒ Symbol
Get the mouse button state. Will return ‘:up`, `:down`, `:click`, or `:double_click`.
|
# File 'lib/cura/event/mouse_button.rb', line 17
|
#state=(value) ⇒ Symbol
Set the mouse button state.
29 |
# File 'lib/cura/event/mouse_button.rb', line 29 attribute(:state) { |value| validate_list(value, VALID_STATES) } |
#up? ⇒ Boolean
Get whether the mouse button state is up.
|
# File 'lib/cura/event/mouse_button.rb', line 64
|