Class: Hokusai::KeyboardEvent

Inherits:
Event
  • Object
show all
Extended by:
Forwardable
Defined in:
ui/src/hokusai/events/keyboard.rb

Direct Known Subclasses

KeyPressEvent, KeyUpEvent

Instance Attribute Summary collapse

Attributes inherited from Event

#bubbles, #captures, #stopped

Instance Method Summary collapse

Methods inherited from Event

#bubble, #matches, name, #name, #stop

Constructor Details

#initialize(input, state) ⇒ KeyboardEvent

Returns a new instance of KeyboardEvent.



11
12
13
14
15
# File 'ui/src/hokusai/events/keyboard.rb', line 11

def initialize(input, state)
  @input = input
  @state = state
  @keyboard = input.keyboard
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



9
10
11
# File 'ui/src/hokusai/events/keyboard.rb', line 9

def input
  @input
end

Instance Method Details

#hovered(canvas) ⇒ Object



17
18
19
# File 'ui/src/hokusai/events/keyboard.rb', line 17

def hovered(canvas)
  input.hovered?(canvas)
end

#to_jsonObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'ui/src/hokusai/events/keyboard.rb', line 21

def to_json
  {
    keypress: {
      keycode: code,
      char: char.to_s,
      super: self.super,
      control: ctrl,
      shift: shift,
      alt: alt
    }
  }.to_json
end