-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.go
More file actions
36 lines (28 loc) · 916 Bytes
/
window.go
File metadata and controls
36 lines (28 loc) · 916 Bytes
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
package main
import (
"github.com/andlabs/ui"
)
var CTRLPressed bool = false
type WindowHandler struct {
Window *ui.Window
}
// Gets called when "something" changes in the environment and the Window system needs to tell the application to "redraw" itself.
func (self WindowHandler) Draw(a *ui.Area, db *ui.AreaDrawParams) {
R.Render(a, db)
}
// Stub to match ui.WindowHandler interface
func (self WindowHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {}
// Stub to match ui.WindowHandler interface
func (self WindowHandler) MouseCrossed(a *ui.Area, left bool) {}
// Stub to match ui.WindowHandler interface
func (self WindowHandler) DragBroken(a *ui.Area) {}
func (self WindowHandler) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
if ke.Modifier == ui.Ctrl {
CTRLPressed = true
} else if CTRLPressed && ke.Key == 'c' {
ui.Quit()
} else {
CTRLPressed = false
}
return true
}