Quit immediately on window click

This commit is contained in:
piotr
2021-08-17 00:54:52 +02:00
parent 2960603462
commit 875e7cac4a
2 changed files with 18 additions and 0 deletions

Binary file not shown.

18
main.go
View File

@@ -243,6 +243,15 @@ func main() {
gtk.MainQuit() gtk.MainQuit()
}) })
win.Connect("button-release-event", func(sw *gtk.Window, e *gdk.Event) bool {
btnEvent := gdk.EventButtonNewFromEvent(e)
if btnEvent.Button() == 1 || btnEvent.Button() == 3 {
gtk.MainQuit()
return true
}
return false
})
win.Connect("key-press-event", func(window *gtk.Window, event *gdk.Event) bool { win.Connect("key-press-event", func(window *gtk.Window, event *gdk.Event) bool {
key := &gdk.EventKey{Event: event} key := &gdk.EventKey{Event: event}
switch key.KeyVal() { switch key.KeyVal() {
@@ -316,10 +325,19 @@ func main() {
pinnedFlowBox = setUpPinnedFlowBox() pinnedFlowBox = setUpPinnedFlowBox()
resultWindow, _ = gtk.ScrolledWindowNew(nil, nil) resultWindow, _ = gtk.ScrolledWindowNew(nil, nil)
resultWindow.SetEvents(int(gdk.ALL_EVENTS_MASK))
resultWindow.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) resultWindow.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
resultWindow.Connect("enter-notify-event", func() { resultWindow.Connect("enter-notify-event", func() {
cancelClose() cancelClose()
}) })
resultWindow.Connect("button-release-event", func(sw *gtk.ScrolledWindow, e *gdk.Event) bool {
btnEvent := gdk.EventButtonNewFromEvent(e)
if btnEvent.Button() == 1 || btnEvent.Button() == 3 {
gtk.MainQuit()
return true
}
return false
})
outerVBox.PackStart(resultWindow, true, true, 10) outerVBox.PackStart(resultWindow, true, true, 10)
resultsWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0) resultsWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)