From 9aafc45c0b50dba5048a58e0076002471a2c8306 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 5 Feb 2024 15:04:01 -0600 Subject: [PATCH] fix textbox Signed-off-by: Jeff Carr --- add.go | 6 +++--- checkbox.go | 2 +- combobox.go | 2 +- dropdown.go | 6 +++--- place.go | 2 +- setText.go | 2 ++ slider.go | 2 +- spinner.go | 2 +- textbox.go | 6 ++++-- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/add.go b/add.go index fd373a7..20d734f 100644 --- a/add.go +++ b/add.go @@ -30,13 +30,13 @@ func add(n *tree.Node) { newSlider(p, n) case widget.Dropdown: newDropdown(p, n) - setText(n, widget.GetString(n.State.Value)) + setText(n, n.State.DefaultS) case widget.Combobox: newCombobox(p, n) - setText(n, widget.GetString(n.State.Value)) + setText(n, n.State.DefaultS) case widget.Textbox: newTextbox(p, n) - setText(n, widget.GetString(n.State.Value)) + setText(n, n.State.DefaultS) /* case widget.Image: newImage(p, n) diff --git a/checkbox.go b/checkbox.go index b2576d7..f85c0d6 100644 --- a/checkbox.go +++ b/checkbox.go @@ -21,7 +21,7 @@ func newCheckbox(p *tree.Node, n *tree.Node) { newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) { var b bool b = newt.checked() - n.SetValue(b) + n.State.Checked = b log.Log(ANDLABS, "Checkbox is now =", b) me.myTree.SendUserEvent(n) }) diff --git a/combobox.go b/combobox.go index 18e16be..21fac61 100644 --- a/combobox.go +++ b/combobox.go @@ -23,7 +23,7 @@ func newCombobox(p, n *tree.Node) { newt.val = make(map[int]string) cb.OnChanged(func(spin *ui.EditableCombobox) { - n.SetValue(spin.Text()) + n.State.CurrentS = spin.Text() log.Log(ANDLABS, "combobox changed ="+spin.Text()+".") me.myTree.SendUserEvent(n) }) diff --git a/dropdown.go b/dropdown.go index 5376c13..2aee84c 100644 --- a/dropdown.go +++ b/dropdown.go @@ -27,9 +27,9 @@ func newDropdown(p, n *tree.Node) { i := spin.Selected() if newt.val == nil { log.Log(ERROR, "make map didn't work") - n.SetValue("map did not work. ui.Combobox error") + n.State.CurrentS = "map did not work. ui.Combobox error" } else { - n.SetValue(newt.val[i]) + n.State.CurrentS = newt.val[i] } me.myTree.SendUserEvent(n) }) @@ -93,7 +93,7 @@ func setDropdownName(n *tree.Node, s string) bool { for i, tmp := range tk.val { if s == tmp { - n.SetValue(s) + n.State.CurrentS = s setDropdownInt(n, i) log.Log(ANDLABS, "SetDropdownInt() worked", tmp, i) return true diff --git a/place.go b/place.go index 657bab5..54cfe0b 100644 --- a/place.go +++ b/place.go @@ -91,7 +91,7 @@ func place(p *tree.Node, n *tree.Node) bool { panic("tk.uiControl == nil") } log.Log(ERROR, "CHECK LOGIC ON THIS. APPENDING directly into a window without a tab") - ptk.uiTab.Append(widget.GetString(n.State.Value), tk.uiControl) + ptk.uiTab.Append(n.State.Label, tk.uiControl) ptk.boxC += 1 return true case widget.Box: diff --git a/setText.go b/setText.go index 0ff87c1..cf51575 100644 --- a/setText.go +++ b/setText.go @@ -11,6 +11,7 @@ func setText(n *tree.Node, name string) { var tk *guiWidget tk = n.TK.(*guiWidget) + log.Info("setText() START with text =", name, n.WidgetType) log.Log(CHANGE, "setText() START with text =", name) if tk == nil { log.Log(ERROR, "setText error. tk == nil", n.GetProgName(), n.WidgetId) @@ -28,6 +29,7 @@ func setText(n *tree.Node, name string) { case widget.Checkbox: tk.uiCheckbox.SetText(name) case widget.Textbox: + log.Info("setText() on Textbox START with text =", name) if tk.uiEntry != nil { tk.uiEntry.SetText(name) } diff --git a/slider.go b/slider.go index f6c8666..04c0a02 100644 --- a/slider.go +++ b/slider.go @@ -22,7 +22,7 @@ func newSlider(p, n *tree.Node) { newt.uiControl = s s.OnChanged(func(spin *ui.Slider) { - n.SetValue(newt.uiSlider.Value()) + n.State.CurrentI = newt.uiSlider.Value() me.myTree.SendUserEvent(n) }) diff --git a/spinner.go b/spinner.go index 8e7ccbb..03f4296 100644 --- a/spinner.go +++ b/spinner.go @@ -18,7 +18,7 @@ func newSpinner(p, n *tree.Node) { newt.uiControl = s s.OnChanged(func(s *ui.Spinbox) { - n.SetValue(newt.uiSpinbox.Value()) + n.State.CurrentI = newt.uiSpinbox.Value() me.myTree.SendUserEvent(n) }) diff --git a/textbox.go b/textbox.go index 226c158..e9e2cad 100644 --- a/textbox.go +++ b/textbox.go @@ -17,18 +17,20 @@ func newTextbox(p, n *tree.Node) { e := ui.NewEntry() newt.uiEntry = e newt.uiControl = e + newt.uiEntry.SetText(n.State.DefaultS) e.OnChanged(func(spin *ui.Entry) { - n.SetValue(spin.Text()) + n.State.CurrentS = spin.Text() me.myTree.SendUserEvent(n) }) } else { e := ui.NewNonWrappingMultilineEntry() newt.uiMultilineEntry = e newt.uiControl = e + newt.uiMultilineEntry.SetText(n.State.DefaultS) e.OnChanged(func(spin *ui.MultilineEntry) { - n.SetValue(spin.Text()) + n.State.CurrentS = spin.Text() me.myTree.SendUserEvent(n) }) }