summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/textbox.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
committerJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
commit8dbf5a09097b7868e9218bf98716c57eac998a10 (patch)
treeab3bdfeaf5a59a55de9d2a6661d2d824090491e5 /toolkit/andlabs/textbox.go
parentf3bb68396afa7452ecf1c8d4744c825a9d81057c (diff)
lots cleaner code between the pluginv0.6.1
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 <[email protected]>
Diffstat (limited to 'toolkit/andlabs/textbox.go')
-rw-r--r--toolkit/andlabs/textbox.go93
1 files changed, 62 insertions, 31 deletions
diff --git a/toolkit/andlabs/textbox.go b/toolkit/andlabs/textbox.go
index cb6075d..e916fd9 100644
--- a/toolkit/andlabs/textbox.go
+++ b/toolkit/andlabs/textbox.go
@@ -5,19 +5,32 @@ import "git.wit.org/wit/gui/toolkit"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
-func (t andlabsT) NewTextbox(name string) *andlabsT {
- var newt andlabsT
+func newTextbox(parentW *toolkit.Widget, w *toolkit.Widget) {
+ log(debugToolkit, "NewTexbox()", w.Name)
- log(debugToolkit, "gui.Toolkit.NewTextbox()", name)
+ t := mapToolkits[parentW]
+ if (t == nil) {
+ listMap(debugError)
+ log(debugError, "newTextbox() listMap()")
+ log(debugError, "FFFFFFFFFFFF listMap()")
+ log(debugError, "FFFFFFFFFFFF listMap()")
+ }
+ // t.NewTextbox(w)
+// func (t andlabsT) NewTextbox(w *toolkit.Widget) *andlabsT {
+ var newt *andlabsT
+ newt = new(andlabsT)
+
+ log(debugToolkit, "gui.Toolkit.NewTextbox()", w.Name)
if t.broken() {
- return nil
+ return
}
c := ui.NewNonWrappingMultilineEntry()
newt.uiMultilineEntry = c
newt.uiBox = t.uiBox
- newt.Name = name
+ newt.Name = w.Name
+ newt.tw = w
if (defaultBehavior) {
t.uiBox.Append(c, true)
} else {
@@ -25,41 +38,59 @@ func (t andlabsT) NewTextbox(name string) *andlabsT {
}
c.OnChanged(func(spin *ui.MultilineEntry) {
- newt.commonChange("Textbox")
+ w.S = newt.uiMultilineEntry.Text()
+ // this is still dangerous
+ // newt.commonChange(newt.tw)
+ log(debugChange, "Not yet safe to trigger on change for ui.MultilineEntry")
})
-
- return &newt
+ mapWidgetsToolkits(w, newt)
}
-func NewTextbox(parentW *toolkit.Widget, w *toolkit.Widget) {
- var t, newt *andlabsT
- log(debugToolkit, "gui.andlabs.NewTextbox()", w.Name)
- t = mapToolkits[parentW]
- if (t == nil) {
- log(debugToolkit, "go.andlabs.NewTextbox() toolkit struct == nil. name=", parentW.Name, w.Name)
+func doTextbox(p *toolkit.Widget, c *toolkit.Widget) {
+ if broken(c) {
return
}
-
- if t.broken() {
+ if (c.Action == "New") {
+ newTextbox(p, c)
return
}
- newt = new(andlabsT)
-
- newt.uiLabel = ui.NewLabel(w.Name)
- newt.uiBox = t.uiBox
-
- log(debugToolkit, "gui.Toolbox.NewTextbox() about to append to Box parent t:", w.Name)
- t.Dump()
- log(debugToolkit, "gui.Toolbox.NewTextbox() about to append to Box new t:", w.Name)
- newt.Dump()
-
- if (t.uiBox != nil) {
- t.uiBox.Append(newt.uiLabel, false)
- } else {
- log(debugToolkit, "ERROR: wit/gui andlabs couldn't place this Textbox in a box")
+ ct := mapToolkits[c]
+ if (ct == nil) {
+ log(true, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
+ return
+ }
+ if ct.broken() {
+ log(true, "Textbox() ct.broken", ct)
return
}
+ if (ct.uiMultilineEntry == nil) {
+ log(debugError, "Textbox() uiMultilineEntry == nil", ct)
+ return
+ }
+ // the dns control panel isn't crashing anymore (?)
+ Queue(ct.doSimpleAction)
+}
- mapWidgetsToolkits(w, newt)
+func (t *andlabsT) doSimpleAction() {
+ if (t.tw == nil) {
+ log(true, "doSimpleAction() got an empty widget")
+ log(true, "THIS SHOULD NEVER HAPPEN")
+ panic("crap. panic. widget == nil")
+ }
+ log(debugChange, "Going to attempt:", t.tw.Action)
+ switch t.tw.Action {
+ case "Enable":
+ t.uiMultilineEntry.Enable()
+ case "Disable":
+ t.uiMultilineEntry.Disable()
+ case "Show":
+ t.uiMultilineEntry.Show()
+ case "Hide":
+ t.uiMultilineEntry.Hide()
+ case "Set":
+ t.uiMultilineEntry.SetText(t.tw.S)
+ default:
+ log(debugError, "Can't do", t.tw.Action, "to a Textbox")
+ }
}