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 /text.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 'text.go')
| -rw-r--r-- | text.go | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -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()") +} |
