fix textbox

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-05 15:04:01 -06:00
parent 1e98d2607b
commit 9aafc45c0b
9 changed files with 17 additions and 13 deletions

6
add.go
View File

@ -30,13 +30,13 @@ func add(n *tree.Node) {
newSlider(p, n) newSlider(p, n)
case widget.Dropdown: case widget.Dropdown:
newDropdown(p, n) newDropdown(p, n)
setText(n, widget.GetString(n.State.Value)) setText(n, n.State.DefaultS)
case widget.Combobox: case widget.Combobox:
newCombobox(p, n) newCombobox(p, n)
setText(n, widget.GetString(n.State.Value)) setText(n, n.State.DefaultS)
case widget.Textbox: case widget.Textbox:
newTextbox(p, n) newTextbox(p, n)
setText(n, widget.GetString(n.State.Value)) setText(n, n.State.DefaultS)
/* /*
case widget.Image: case widget.Image:
newImage(p, n) newImage(p, n)

View File

@ -21,7 +21,7 @@ func newCheckbox(p *tree.Node, n *tree.Node) {
newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) { newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) {
var b bool var b bool
b = newt.checked() b = newt.checked()
n.SetValue(b) n.State.Checked = b
log.Log(ANDLABS, "Checkbox is now =", b) log.Log(ANDLABS, "Checkbox is now =", b)
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })

View File

@ -23,7 +23,7 @@ func newCombobox(p, n *tree.Node) {
newt.val = make(map[int]string) newt.val = make(map[int]string)
cb.OnChanged(func(spin *ui.EditableCombobox) { cb.OnChanged(func(spin *ui.EditableCombobox) {
n.SetValue(spin.Text()) n.State.CurrentS = spin.Text()
log.Log(ANDLABS, "combobox changed ="+spin.Text()+".") log.Log(ANDLABS, "combobox changed ="+spin.Text()+".")
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })

View File

@ -27,9 +27,9 @@ func newDropdown(p, n *tree.Node) {
i := spin.Selected() i := spin.Selected()
if newt.val == nil { if newt.val == nil {
log.Log(ERROR, "make map didn't work") 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 { } else {
n.SetValue(newt.val[i]) n.State.CurrentS = newt.val[i]
} }
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })
@ -93,7 +93,7 @@ func setDropdownName(n *tree.Node, s string) bool {
for i, tmp := range tk.val { for i, tmp := range tk.val {
if s == tmp { if s == tmp {
n.SetValue(s) n.State.CurrentS = s
setDropdownInt(n, i) setDropdownInt(n, i)
log.Log(ANDLABS, "SetDropdownInt() worked", tmp, i) log.Log(ANDLABS, "SetDropdownInt() worked", tmp, i)
return true return true

View File

@ -91,7 +91,7 @@ func place(p *tree.Node, n *tree.Node) bool {
panic("tk.uiControl == nil") panic("tk.uiControl == nil")
} }
log.Log(ERROR, "CHECK LOGIC ON THIS. APPENDING directly into a window without a tab") 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 ptk.boxC += 1
return true return true
case widget.Box: case widget.Box:

View File

@ -11,6 +11,7 @@ func setText(n *tree.Node, name string) {
var tk *guiWidget var tk *guiWidget
tk = n.TK.(*guiWidget) tk = n.TK.(*guiWidget)
log.Info("setText() START with text =", name, n.WidgetType)
log.Log(CHANGE, "setText() START with text =", name) log.Log(CHANGE, "setText() START with text =", name)
if tk == nil { if tk == nil {
log.Log(ERROR, "setText error. tk == nil", n.GetProgName(), n.WidgetId) 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: case widget.Checkbox:
tk.uiCheckbox.SetText(name) tk.uiCheckbox.SetText(name)
case widget.Textbox: case widget.Textbox:
log.Info("setText() on Textbox START with text =", name)
if tk.uiEntry != nil { if tk.uiEntry != nil {
tk.uiEntry.SetText(name) tk.uiEntry.SetText(name)
} }

View File

@ -22,7 +22,7 @@ func newSlider(p, n *tree.Node) {
newt.uiControl = s newt.uiControl = s
s.OnChanged(func(spin *ui.Slider) { s.OnChanged(func(spin *ui.Slider) {
n.SetValue(newt.uiSlider.Value()) n.State.CurrentI = newt.uiSlider.Value()
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })

View File

@ -18,7 +18,7 @@ func newSpinner(p, n *tree.Node) {
newt.uiControl = s newt.uiControl = s
s.OnChanged(func(s *ui.Spinbox) { s.OnChanged(func(s *ui.Spinbox) {
n.SetValue(newt.uiSpinbox.Value()) n.State.CurrentI = newt.uiSpinbox.Value()
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })

View File

@ -17,18 +17,20 @@ func newTextbox(p, n *tree.Node) {
e := ui.NewEntry() e := ui.NewEntry()
newt.uiEntry = e newt.uiEntry = e
newt.uiControl = e newt.uiControl = e
newt.uiEntry.SetText(n.State.DefaultS)
e.OnChanged(func(spin *ui.Entry) { e.OnChanged(func(spin *ui.Entry) {
n.SetValue(spin.Text()) n.State.CurrentS = spin.Text()
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })
} else { } else {
e := ui.NewNonWrappingMultilineEntry() e := ui.NewNonWrappingMultilineEntry()
newt.uiMultilineEntry = e newt.uiMultilineEntry = e
newt.uiControl = e newt.uiControl = e
newt.uiMultilineEntry.SetText(n.State.DefaultS)
e.OnChanged(func(spin *ui.MultilineEntry) { e.OnChanged(func(spin *ui.MultilineEntry) {
n.SetValue(spin.Text()) n.State.CurrentS = spin.Text()
me.myTree.SendUserEvent(n) me.myTree.SendUserEvent(n)
}) })
} }