From 8dbf5a09097b7868e9218bf98716c57eac998a10 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 1 Mar 2023 11:35:36 -0600 Subject: lots cleaner code between the plugin Queue() around SetText is helping userspace crashing merge forceDump(bool) into Dump() debugging output configuration is pretty clean keep cutting down duplicate things --gui-verbose flag works make label "standard" code add debug.FreeOSMemory() move the GO language internals to display in the GUI update push to do tags and go to github.com/wit-go/ remove the other license file it might be confusing golang.org and github proper WidgetType added a Quit() button Signed-off-by: Jeff Carr --- cmds/textbox/main.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'cmds/textbox') diff --git a/cmds/textbox/main.go b/cmds/textbox/main.go index b260681..44431b7 100644 --- a/cmds/textbox/main.go +++ b/cmds/textbox/main.go @@ -11,8 +11,6 @@ import ( type LogOptions struct { LogFile string Verbose bool - // GuiDebug bool `help:"open up the wit/gui Debugging Window"` - // GuiDemo bool `help:"open the wit/gui Demo Window"` User string `arg:"env:USER"` } @@ -45,11 +43,15 @@ func main() { func initGUI() { var w *gui.Node gui.Config.Title = "Hello World" - gui.Config.Width = 640 - gui.Config.Height = 480 + gui.Config.Width = 642 + gui.Config.Height = 481 gui.Config.Exit = myDefaultExit w = gui.NewWindow() + w.Custom = func () { + log.Println("myDefaultExit(w)") + myDefaultExit(w) + } w.Dump() addDemoTab(w, "A Simple Tab Demo") addDemoTab(w, "A Second Tab") @@ -57,6 +59,9 @@ func initGUI() { if (args.GuiDebug) { gui.DebugWindow() } + if (args.GuiVerbose) { + gui.SetDebug(true) + } } func addDemoTab(window *gui.Node, title string) { @@ -71,18 +76,19 @@ func addDemoTab(window *gui.Node, title string) { dd.AddDropdownName("more 1") dd.AddDropdownName("more 2") dd.AddDropdownName("more 3") - dd.OnChanged = func(*gui.Node) { - s := dd.GetText() - tb.SetText("hello world " + args.User + "\n" + s) - } - g2 = newNode.NewGroup("group 2") tb = g2.NewTextbox("tb") log.Println("tb =", tb.GetText()) - tb.OnChanged = func(*gui.Node) { + tb.Custom = func() { s := tb.GetText() log.Println("text =", s) } + + dd.Custom = func() { + s := dd.GetText() + log.Println("hello world " + args.User + "\n" + s + "\n") + tb.SetText("hello world " + args.User + "\n" + s + "\n") + } } func myDefaultExit(n *gui.Node) { -- cgit v1.2.3