diff options
| author | Jeff Carr <[email protected]> | 2022-10-19 13:23:22 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-10-19 13:23:22 -0500 |
| commit | f3af1f5b7ff78b3f73d7510622fc9633dec36d35 (patch) | |
| tree | e4868584d5e19942938aaa122b2e1cab377db000 /toolkit/andlabs/window.go | |
| parent | f7b1036e544238d65b0e3ad46d08075aa4177032 (diff) | |
Refactor to 'gui/toolkit/'
* add a example cmds/consolemouse
uses a console button to launch the andlabs/ui
* fix wrong return value in toolkit/NewLabel()
* redirect STDIN output to a file
* wonderful fix of Window() exit
* finally remove the ancient stupid variables x & y
* phase out struct 'box' and use 'node' instead
* better names for things: use NewFoo() and NewBar()
Diffstat (limited to 'toolkit/andlabs/window.go')
| -rw-r--r-- | toolkit/andlabs/window.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/toolkit/andlabs/window.go b/toolkit/andlabs/window.go new file mode 100644 index 0000000..f0357ed --- /dev/null +++ b/toolkit/andlabs/window.go @@ -0,0 +1,45 @@ +package toolkit + +import ( + "log" + "os" + + "github.com/andlabs/ui" + _ "github.com/andlabs/ui/winmanifest" +) + +func (t *Toolkit) MessageWindow(msg1 string, msg2 string) { + ui.MsgBox(t.uiWindow, msg1, msg2) +} + +func (t *Toolkit) ErrorWindow(msg1 string, msg2 string) { + ui.MsgBoxError(t.uiWindow, msg1, msg2) +} + +func NewWindow(title string, x int, y int) *Toolkit { + var t Toolkit + log.Println("toolkit NewWindow", title, x, y) + w := ui.NewWindow(title, x, y, false) + w.SetBorderless(false) + w.OnClosing(func(*ui.Window) bool { + log.Println("ui.Window().OnExit() SHOULD ATTEMPT CALLBACK here") + t.Dump() + if (t.OnExit != nil) { + log.Println("ui.Window().OnExit() ATTEMPTING toolkit.OnExit CALLBACK") + t.OnExit(&t) + } + if (t.Custom != nil) { + log.Println("ui.Window().Custom() ATTEMPTING toolkit.Custom CALLBACK") + t.Custom() + } + log.Println("ui.Window().OnExit() Toolkit.OnExit is nil") + t.Dump() + os.Exit(0) + return true + }) + w.SetMargined(true) + w.Show() + t.uiWindow = w + t.UiWindowBad = w // deprecate this as soon as possible + return &t +} |
