summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/button.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-10-19 13:23:22 -0500
committerJeff Carr <[email protected]>2022-10-19 13:23:22 -0500
commitf3af1f5b7ff78b3f73d7510622fc9633dec36d35 (patch)
treee4868584d5e19942938aaa122b2e1cab377db000 /toolkit/andlabs/button.go
parentf7b1036e544238d65b0e3ad46d08075aa4177032 (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/button.go')
-rw-r--r--toolkit/andlabs/button.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/toolkit/andlabs/button.go b/toolkit/andlabs/button.go
new file mode 100644
index 0000000..3278c09
--- /dev/null
+++ b/toolkit/andlabs/button.go
@@ -0,0 +1,50 @@
+package toolkit
+
+import "log"
+import "os"
+
+import "github.com/andlabs/ui"
+import _ "github.com/andlabs/ui/winmanifest"
+
+// make new Group here
+func (t Toolkit) NewButton(name string) *Toolkit {
+ var newt Toolkit
+ var b *ui.Button
+
+ if (t.uiBox == nil) {
+ log.Println("gui.ToolboxNode.NewButton() node.UiBox == nil. I can't add a range UI element without a place to put it")
+ log.Println("probably could just make a box here?")
+ os.Exit(0)
+ return nil
+ }
+
+ log.Println("gui.Toolbox.NewGroup() create", name)
+ b = ui.NewButton(name)
+ newt.uiButton = b
+
+ b.OnClicked(func(*ui.Button) {
+ log.Println("TODO: IN TOOLKIT GOROUTINE. SHOULD LEAVE HERE VIA channels. button name =", name)
+ t.Dump()
+ newt.Dump()
+ log.Println("wit/gui/toolkit NewButton() Should do something here")
+ if (newt.Custom == nil) {
+ log.Println("wit/gui/toolkit NewButton() toolkit.Custom == nil")
+ } else {
+ log.Println("wit/gui/toolkit NewButton() toolkit.Custom() START")
+ newt.Custom()
+ log.Println("wit/gui/toolkit NewButton() toolkit.Custom() END")
+ }
+ if (t.Custom == nil) {
+ log.Println("wit/gui/toolkit NewButton() parent toolkit.Custom == nil")
+ } else {
+ log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() START (IS THIS A BAD IDEA?)")
+ t.Custom()
+ log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() END (IS THIS A BAD IDEA?)")
+ }
+ log.Println("TODO: LEFT TOOLKIT GOROUTINE button name =", name)
+ })
+
+ t.uiBox.Append(b, false)
+
+ return &newt
+}