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.
14 15 16 17 18 19 |
# File 'lib/cura/event/mouse_button.rb', line 14 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 78
|
#down? ⇒ Boolean
Get whether the mouse button state is down.
|
# File 'lib/cura/event/mouse_button.rb', line 73
|
#left? ⇒ Boolean
Get whether the mouse button state occurred the left button.
|
# File 'lib/cura/event/mouse_button.rb', line 49
|
#middle? ⇒ Boolean
Get whether the mouse button state occurred the middle button.
|
# File 'lib/cura/event/mouse_button.rb', line 54
|
#name ⇒ Symbol
Get the mouse button name. Will return ‘:left`, `:middle`, or `:right`.
|
# File 'lib/cura/event/mouse_button.rb', line 35
|
#name=(value) ⇒ Symbol
Set the mouse button name.
47 |
# File 'lib/cura/event/mouse_button.rb', line 47 attribute(:name) { |value| validate_list(value, VALID_NAMES) } |
#right? ⇒ Boolean
Get whether the mouse button state occurred the right button.
64 65 66 |
# File 'lib/cura/event/mouse_button.rb', line 64 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 21
|
#state=(value) ⇒ Symbol
Set the mouse button state.
33 |
# File 'lib/cura/event/mouse_button.rb', line 33 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 68
|