Class: RubySketch::VirtualKey::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysketch/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ Dispatcher

Returns a new instance of Dispatcher.



89
90
91
92
93
94
95
# File 'lib/rubysketch/window.rb', line 89

def initialize(view)
  @view      = view
  @pressings = {}

  @repeat_first_delay = 0.3
  @repeat_interval    = 0.1
end

Instance Attribute Details

#repeat_first_delayObject

Returns the value of attribute repeat_first_delay.



87
88
89
# File 'lib/rubysketch/window.rb', line 87

def repeat_first_delay
  @repeat_first_delay
end

#repeat_intervalObject

Returns the value of attribute repeat_interval.



87
88
89
# File 'lib/rubysketch/window.rb', line 87

def repeat_interval
  @repeat_interval
end

Instance Method Details

#key_down(chars, key) ⇒ Object



97
98
99
100
# File 'lib/rubysketch/window.rb', line 97

def key_down(chars, key)
  dispatch :down, chars, key
  pressing chars, key
end

#key_up(chars, key) ⇒ Object



102
103
104
105
# File 'lib/rubysketch/window.rb', line 102

def key_up(chars, key)
  dispatch :up, chars, key
  released chars, key
end

#pressing?(chars, key) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/rubysketch/window.rb', line 107

def pressing?(chars, key)
  @pressings.key? to_key(chars, key)
end