-
Notifications
You must be signed in to change notification settings - Fork 46
/
events.go
127 lines (102 loc) · 3.25 KB
/
events.go
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
Copyright 2012 the go.wde authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package wde
import (
"image"
)
type Button int
const (
LeftButton Button = 1 << iota
MiddleButton
RightButton
WheelUpButton
WheelDownButton
WheelLeftButton // only supported by xgb/win backends atm
WheelRightButton // only supported by xgb/win backends atm
)
type Event int
// MouseEvent is used for data common to all mouse events, and should not appear as an event received by the caller program.
type MouseEvent struct {
Event
Where image.Point
}
// MouseMovedEvent is for when the mouse moves within the window.
type MouseMovedEvent struct {
MouseEvent
From image.Point
}
// MouseButtonEvent is used for data common to all mouse button events, and should not appear as an event received by the caller program.
type MouseButtonEvent struct {
MouseEvent
Which Button
}
// MouseDownEvent is for when the mouse is clicked within the window.
type MouseDownEvent MouseButtonEvent
// MouseUpEvent is for when the mouse is unclicked within the window.
type MouseUpEvent MouseButtonEvent
// MouseDraggedEvent is for when the mouse is moved while a button is pressed.
type MouseDraggedEvent struct {
MouseMovedEvent
Which Button
}
// MouseEnteredEvent is for when the mouse enters a window.
type MouseEnteredEvent MouseMovedEvent
// MouseExitedEvent is for when the mouse exits a window.
type MouseExitedEvent MouseMovedEvent
// MagnifyEvent is used to represent a magnification gesture.
type MagnifyEvent struct {
Event
Where image.Point
Magnification float64 // the multiplicative scale factor
}
// RotateEvent is used to represent a rotation gesture.
type RotateEvent struct {
Event
Where image.Point
Rotation float64 // measured in degrees; positive == clockwise
}
// Scroll Event is used to represent a scrolling gesture.
type ScrollEvent struct {
Event
Where image.Point
Delta image.Point
}
// KeyEvent is used for data common to all key events, and should not appear as an event received by the caller program.
type KeyEvent struct {
Key string
}
// KeyDownEvent is for when a key is pressed.
type KeyDownEvent KeyEvent
// KeyUpEvent is for when a key is unpressed.
type KeyUpEvent KeyEvent
// KeyTypedEvent is for when a key is typed.
type KeyTypedEvent struct {
KeyEvent
/*
The glyph is the string corresponding to what the user wants to have typed in
whatever data entry is active.
*/
Glyph string
/*
The "+" joined set of keys (not glyphs) participating in the chord completed
by this key event. The keys will be in a consistent order, no matter what
order they are pressed in.
*/
Chord string
}
// ResizeEvent is for when the window changes size.
type ResizeEvent struct {
Width, Height int
}
// CloseEvent is for when the window is closed.
type CloseEvent struct{}