trap window close and correctly exit

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-23 13:44:53 -07:00
parent f283a656dc
commit 6dadeae3fd
3 changed files with 27 additions and 17 deletions

14
area.go
View File

@ -7,10 +7,6 @@ import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew" import "github.com/davecgh/go-spew/spew"
func areaClick(a int, b string) {
log.Println("GOT areaClick(a,b) =", a, b)
}
func makeSplashArea(custom func(int, string)) *ui.Area { func makeSplashArea(custom func(int, string)) *ui.Area {
// make this button just to get the default font (but don't display the button) // make this button just to get the default font (but don't display the button)
// There should be another way to do this (?) // There should be another way to do this (?)
@ -80,7 +76,9 @@ func (ah areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
func (ah areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) { func (ah areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
log.Println("GOT MouseEvent()") log.Println("GOT MouseEvent()")
spew.Dump(me) if (Data.Debug) {
spew.Dump(me)
}
if (me.Down == 1) { if (me.Down == 1) {
log.Println("GOT MOUSE DOWN") log.Println("GOT MOUSE DOWN")
log.Println("GOT MOUSE DOWN") log.Println("GOT MOUSE DOWN")
@ -90,10 +88,10 @@ func (ah areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
log.Println("GOT MOUSE UP") log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP") log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP") log.Println("GOT MOUSE UP")
// splashWin.Destroy() if (Data.ButtonClickNew != nil) {
// ui.Quit() Data.ButtonClickNew(nil)
}
} }
areaClick(1, "done")
} }
func (ah areaHandler) MouseCrossed(a *ui.Area, left bool) { func (ah areaHandler) MouseCrossed(a *ui.Area, left bool) {

View File

@ -30,13 +30,15 @@ func ShowSplashBox(vbox *ui.Box, atest chan int, custom func(int, string)) *ui.B
version := "Version: " + Data.Version version := "Version: " + Data.Version
newbox.Append(ui.NewLabel(version), false) newbox.Append(ui.NewLabel(version), false)
if (Data.GitCommit != "") { if (Data.Debug) {
tmp := "git rev-list: " + Data.GitCommit if (Data.GitCommit != "") {
newbox.Append(ui.NewLabel(tmp), false) tmp := "git rev-list: " + Data.GitCommit
} newbox.Append(ui.NewLabel(tmp), false)
if (Data.GoVersion != "") { }
tmp := "go build version: " + Data.GoVersion if (Data.GoVersion != "") {
newbox.Append(ui.NewLabel(tmp), false) tmp := "go build version: " + Data.GoVersion
newbox.Append(ui.NewLabel(tmp), false)
}
} }
okButton := CreateButton("OK", "DONE", custom) okButton := CreateButton("OK", "DONE", custom)

View File

@ -61,11 +61,21 @@ func makeCloudWindow() {
Data.cloudWindow = ui.NewWindow("", 640, 480, true) Data.cloudWindow = ui.NewWindow("", 640, 480, true)
// cloudWindow.SetBorderless(true) // cloudWindow.SetBorderless(true)
Data.cloudWindow.OnClosing(func(*ui.Window) bool { Data.cloudWindow.OnClosing(func(*ui.Window) bool {
ui.Quit() if (Data.ButtonClickNew != nil) {
log.Println("Data.ButtonClickNew() START QUIT")
Data.State = "QUIT"
Data.ButtonClickNew(nil)
}
// ui.Quit()
return true return true
}) })
ui.OnShouldQuit(func() bool { ui.OnShouldQuit(func() bool {
Data.cloudWindow.Destroy() if (Data.ButtonClickNew != nil) {
log.Println("Data.ButtonClickNew() START QUIT")
Data.State = "QUIT"
Data.ButtonClickNew(nil)
}
// Data.cloudWindow.Destroy()
return true return true
}) })