2019-06-02 15:40:44 -05:00
|
|
|
package gui
|
|
|
|
|
2024-01-05 13:18:44 -06:00
|
|
|
import "go.wit.com/gui/widget"
|
2021-10-31 14:21:36 -05:00
|
|
|
|
2023-05-09 08:38:33 -05:00
|
|
|
func (parent *Node) NewButton(name string, custom func()) *Node {
|
2024-01-05 13:18:44 -06:00
|
|
|
newNode := parent.newNode(name, widget.Button)
|
2023-05-09 20:25:37 -05:00
|
|
|
newNode.Custom = custom
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2024-01-06 13:53:15 -06:00
|
|
|
if ! newNode.hidden {
|
|
|
|
a := newAction(newNode, widget.Add)
|
|
|
|
sendAction(a)
|
|
|
|
}
|
2021-10-31 14:21:36 -05:00
|
|
|
return newNode
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
|
2023-04-03 10:26:47 -05:00
|
|
|
// find widget by number
|
|
|
|
func (n *Node) FindId(i int) (*Node) {
|
|
|
|
if (n == nil) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n.id == i) {
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, child := range n.children {
|
|
|
|
newN := child.FindId(i)
|
|
|
|
if (newN != nil) {
|
|
|
|
return newN
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|