2022-10-20 06:55:42 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
|
|
|
import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
|
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
func commonCallback(n *Node) {
|
|
|
|
// TODO: make all of this common code to all the widgets
|
|
|
|
if (n.OnChanged == nil) {
|
|
|
|
log.Println("Not Running n.OnChanged(n) == nil")
|
|
|
|
} else {
|
|
|
|
log.Println("Running n.OnChanged(n)")
|
|
|
|
n.OnChanged(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n.custom == nil) {
|
|
|
|
log.Println("Not Running n.custom(n) == nil")
|
|
|
|
} else {
|
|
|
|
log.Println("Running n.custom()")
|
|
|
|
n.custom()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-20 06:55:42 -05:00
|
|
|
func (n *Node) NewDropdown(name string) *Node {
|
|
|
|
var newT *toolkit.Toolkit
|
|
|
|
var sNode *Node
|
|
|
|
|
|
|
|
log.Println("toolkit.NewDropdown() START", name)
|
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
n.verify()
|
2022-10-20 06:55:42 -05:00
|
|
|
|
|
|
|
sNode = n.New(name + " part1")
|
|
|
|
newT = n.toolkit.NewDropdown(name)
|
|
|
|
newT.Name = name
|
|
|
|
sNode.custom = n.custom
|
|
|
|
newT.Custom = func () {
|
2022-10-21 11:40:08 -05:00
|
|
|
commonCallback(sNode)
|
2022-10-20 06:55:42 -05:00
|
|
|
}
|
|
|
|
sNode.toolkit = newT
|
|
|
|
sNode.Dump()
|
|
|
|
// panic("checking Custom()")
|
|
|
|
|
|
|
|
return sNode
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) AddDropdown(name string) {
|
|
|
|
n.toolkit.AddDropdown(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) SetDropdown(i int) {
|
|
|
|
n.toolkit.SetDropdown(i)
|
|
|
|
}
|