class Cura::Event::KeyDown
Dispatched when a key's state changes from up to down.
Attributes
name[R]
Get the key name.
@return [Integer]
Public Class Methods
new(attributes={})
click to toggle source
Calls superclass method
Cura::Event::Base::new
# File lib/cura/event/key_down.rb, line 7 def initialize(attributes={}) @control = false super raise ArgumentError, "name must be set" if @name.nil? end
Public Instance Methods
character()
click to toggle source
Get the printable character for the key.
@return [nil, String]
# File lib/cura/event/key_down.rb, line 39 def character Key.character_from_name(@name) end
control?()
click to toggle source
Get whether the key was pressed while holding the control key.
@return [Boolean]
# File lib/cura/event/key_down.rb, line 18 def control? @control end
printable?()
click to toggle source
Get whether the key is printable.
@return [Boolean]
# File lib/cura/event/key_down.rb, line 30 def printable? return false if @control Key.name_is_printable?(@name) end
Protected Instance Methods
control=(value)
click to toggle source
Set if the key was pressed while holding the control key.
@param [Boolean] value @return [Boolean]
# File lib/cura/event/key_down.rb, line 49 def control=(value) @control = !!value end
name=(value)
click to toggle source
Set the key name.
@param [#to_sym] value @return [String]
# File lib/cura/event/key_down.rb, line 57 def name=(value) @name = value.to_sym end