Class: Hokusai::MouseEvent
- Inherits:
-
Event
- Object
- Event
- Hokusai::MouseEvent
show all
- Extended by:
- Forwardable
- Defined in:
- ui/src/hokusai/events/mouse.rb
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) ⇒ MouseEvent
Returns a new instance of MouseEvent.
7
8
9
10
11
12
13
14
|
# File 'ui/src/hokusai/events/mouse.rb', line 7
def initialize(input, state)
@input = input
@mouse = input.mouse
@left = @mouse.left
@right = @mouse.right
@middle = @mouse.middle
@state = state
end
|
Instance Attribute Details
Returns the value of attribute input.
5
6
7
|
# File 'ui/src/hokusai/events/mouse.rb', line 5
def input
@input
end
|
#state ⇒ Object
Returns the value of attribute state.
5
6
7
|
# File 'ui/src/hokusai/events/mouse.rb', line 5
def state
@state
end
|
Instance Method Details
#delta ⇒ Object
24
25
26
|
# File 'ui/src/hokusai/events/mouse.rb', line 24
def delta
mouse.delta
end
|
#left ⇒ Object
36
37
38
|
# File 'ui/src/hokusai/events/mouse.rb', line 36
def left
@left
end
|
#middle ⇒ Object
44
45
46
|
# File 'ui/src/hokusai/events/mouse.rb', line 44
def middle
@middle
end
|
#mouse ⇒ Object
16
17
18
|
# File 'ui/src/hokusai/events/mouse.rb', line 16
def mouse
@mouse
end
|
#pos ⇒ Object
20
21
22
|
# File 'ui/src/hokusai/events/mouse.rb', line 20
def pos
mouse.pos
end
|
#right ⇒ Object
40
41
42
|
# File 'ui/src/hokusai/events/mouse.rb', line 40
def right
@right
end
|
28
29
30
|
# File 'ui/src/hokusai/events/mouse.rb', line 28
def scroll
mouse.scroll
end
|
32
33
34
|
# File 'ui/src/hokusai/events/mouse.rb', line 32
def scroll_delta
mouse.scroll_delta
end
|
#to_json ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'ui/src/hokusai/events/mouse.rb', line 48
def to_json
hash = {}
hash[:pos] = { x: pos.x, y: pos.y }
[:left, :right, :middle].each do |button|
hash[button] = {
down: send(button).down,
up: send(button).up,
clicked: send(button).clicked,
released: send(button).released
}
end
hash[:scroll] = scroll
hash[:scroll_delta] = scroll_delta
hash.to_json
end
|