-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.sj
59 lines (51 loc) · 1.28 KB
/
mouse.sj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
mouse_captureElement := empty'heap #element
mouse_capture(element : 'heap #element) {
mouse_captureElement = valid(element)
--c--
SDL_CaptureMouse(true);
--c--
}
mouse_hasCapture(element : 'heap #element) {
ifValid mouse_captureElement {
mouse_captureElement === element
} elseEmpty {
false
}
}
mouse_release(element : 'heap #element) {
console.writeLine("release")
ifValid m : mouse_captureElement {
if m === element {
console.writeLine("release done")
mouse_captureElement = empty'#element
--c--
SDL_CaptureMouse(false);
--c--
}
}
void
}
enum mouseEventType (
move
up
down
)
mouseEvent(
eventType : 'mouseEventType
point : 'point
isCaptured : 'bool
isLeftDown : 'bool
fireChildren(children : 'array!heap #element) {
shouldContinue := true
for i : 0 toReverse children.count {
if shouldContinue {
child : children[i]
shouldContinue = child.fireMouseEvent(parent)
}
}
shouldContinue
}
asString() {
"point : " + point.asString() + " isCaptured : " + isCaptured.asString() + " isLeftDown : " + isLeftDown.asString()
}
) { this }