andlabs/textbox.go

40 lines
750 B
Go

package main
import (
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newTextbox(p, n *tree.Node) {
if notNew(n) {
return
}
newt := new(guiWidget)
if n.State.Range.Low == 1 {
e := ui.NewEntry()
newt.uiEntry = e
newt.uiControl = e
newt.uiEntry.SetText(n.State.DefaultS)
e.OnChanged(func(spin *ui.Entry) {
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.State.CurrentS = spin.Text()
me.myTree.SendUserEvent(n)
})
}
n.TK = newt
place(p, n)
}