summaryrefslogtreecommitdiff
path: root/text.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 /text.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 'text.go')
-rw-r--r--text.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/text.go b/text.go
new file mode 100644
index 0000000..69a9002
--- /dev/null
+++ b/text.go
@@ -0,0 +1,40 @@
+package gui
+
+import "log"
+import "errors"
+
+// import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
+
+// functions for handling text related GUI elements
+
+func (n *Node) NewLabel(text string) *Node {
+ // make new node here
+ newNode := n.New(text)
+ newNode.Dump()
+
+ t := n.Toolkit.NewLabel(text)
+ newNode.Toolkit = t
+
+ return newNode
+}
+
+func (n *Node) SetText(value string) error {
+ log.Println("gui.SetText() value =", value)
+ if (n.Toolkit != nil) {
+ n.Toolkit.SetText(value)
+ return nil
+ }
+ if (n.uiText != nil) {
+ n.uiText.SetText(value)
+ return nil
+ }
+ if (n.uiButton != nil) {
+ n.uiButton.SetText(value)
+ return nil
+ }
+ if (n.uiWindow != nil) {
+ n.uiWindow.SetTitle(value)
+ return nil
+ }
+ return errors.New("nothing found for gui.Node.SetText()")
+}