From f3af1f5b7ff78b3f73d7510622fc9633dec36d35 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 19 Oct 2022 13:23:22 -0500 Subject: 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() --- toolkit/andlabs/label.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'toolkit/andlabs/label.go') diff --git a/toolkit/andlabs/label.go b/toolkit/andlabs/label.go index 23d4927..453412a 100644 --- a/toolkit/andlabs/label.go +++ b/toolkit/andlabs/label.go @@ -1,23 +1,31 @@ package toolkit import "log" +import "os" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" -func NewLabel(b *ui.Box, name string) *Toolkit { +// func NewLabel(b *ui.Box, name string) *Toolkit { + +func (t *Toolkit) NewLabel(name string) *Toolkit { // make new node here log.Println("gui.Toolbox.NewLabel", name) - var t Toolkit - if (b == nil) { + if (t.uiBox == nil) { log.Println("gui.ToolboxNode.NewLabel() node.UiBox == nil. I can't add a range UI element without a place to put it") - return &t + os.Exit(0) + return nil } - l := ui.NewLabel(name) - t.uiLabel = l - t.uiBox = b - t.uiBox.Append(l, false) + var newt Toolkit + newt.uiLabel = ui.NewLabel(name) + newt.uiBox = t.uiBox + t.uiBox.Append(newt.uiLabel, false) + log.Println("parent toolkit") + t.Dump() + log.Println("newt toolkit") + newt.Dump() + // panic("got here") - return &t + return &newt } -- cgit v1.2.3