Skip to content

Commit bb9eb76

Browse files
committed
feat: quit on press ESC
1 parent 4f08e1e commit bb9eb76

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ func setupWindow(title string) *gtk.Window {
5757
win.Connect("destroy", func() {
5858
gtk.MainQuit()
5959
})
60+
// quit on out blur
6061
win.Connect("focus-out-event", func(widget *gtk.Window, event *gdk.Event) bool {
6162
gtk.MainQuit()
6263
return false // Continue with the default behavior
6364
})
65+
// quit on press ESC
66+
win.Connect("key-press-event", func(window *gtk.Window, event *gdk.Event) {
67+
keyEvent := &gdk.EventKey{Event: event}
68+
if keyEvent.KeyVal() == gdk.KEY_Escape {
69+
gtk.MainQuit()
70+
}
71+
})
6472

6573
// vertical button box
6674
mainBox, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 2)

0 commit comments

Comments
 (0)