2019-06-02 13:02:14 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
2021-10-31 19:52:18 -05:00
|
|
|
// import "os"
|
2019-06-03 02:20:28 -05:00
|
|
|
// import "reflect"
|
2019-06-02 13:02:14 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-06-03 02:20:28 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2021-10-31 14:21:36 -05:00
|
|
|
func (n *Node) AddComboBox(title string, s ...string) *Node {
|
2021-10-31 15:46:31 -05:00
|
|
|
newNode := n.AddNode(title)
|
2021-10-31 14:21:36 -05:00
|
|
|
box := n.uiBox
|
|
|
|
if (box == nil) {
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
ecbox := ui.NewEditableCombobox()
|
2021-10-31 15:46:31 -05:00
|
|
|
newNode.uiText = ecbox
|
|
|
|
// newNode.Dump()
|
|
|
|
// log.Println("ecbox", ecbox)
|
2021-10-31 14:21:36 -05:00
|
|
|
|
|
|
|
for id, name := range s {
|
|
|
|
log.Println("Adding Combobox Entry:", id, name)
|
|
|
|
ecbox.Append(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
ecbox.OnChanged(func(*ui.EditableCombobox) {
|
|
|
|
test := ecbox.Text()
|
2021-10-31 15:46:31 -05:00
|
|
|
log.Println("node.Name = '" + newNode.Name + "' text for '" + title + "' is now: '" + test + "'")
|
|
|
|
if (newNode.OnChanged == nil) {
|
|
|
|
log.Println("Not doing custom OnChanged since OnChanged == nil")
|
|
|
|
newNode.Dump()
|
|
|
|
} else {
|
|
|
|
newNode.OnChanged()
|
|
|
|
}
|
2021-10-31 14:21:36 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
box.Append(ecbox, false)
|
|
|
|
|
2021-10-31 15:46:31 -05:00
|
|
|
// newNode.Dump()
|
|
|
|
// panic("junk")
|
2021-10-31 14:21:36 -05:00
|
|
|
return newNode
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) GetText() string {
|
|
|
|
if (n.uiText == nil) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
ecbox := n.uiText
|
|
|
|
return ecbox.Text()
|
|
|
|
}
|