2019-06-02 15:40:44 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
func (n *Node) NewButton(name string, custom func()) *Node {
|
2022-10-20 06:55:42 -05:00
|
|
|
if (n.toolkit == nil) {
|
2022-11-09 08:38:50 -06:00
|
|
|
log.Println("gui.Node.NewButton() filed node.toolkit == nil")
|
|
|
|
panic("gui.Node.NewButton() filed node.toolkit == nil")
|
2021-10-31 14:21:36 -05:00
|
|
|
return n
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
newNode := n.New(name)
|
2022-10-20 06:55:42 -05:00
|
|
|
newNode.toolkit = n.toolkit.NewButton(name)
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2022-11-09 08:38:50 -06:00
|
|
|
log.Println("gui.Node.NewButton()", name)
|
|
|
|
if (PlugGocliOk) {
|
|
|
|
log.Println("wit/gui gocui is loaded", PlugGocliOk)
|
|
|
|
greeter.AddButton(name)
|
|
|
|
log.Println("GOT HERE PlugGocliOk TRUE")
|
|
|
|
} else {
|
|
|
|
log.Println("GOT HERE PlugGocliOk FALSE")
|
|
|
|
}
|
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
// TODO: this is still confusing and probably wrong. This needs to communicate through a channel
|
2022-10-20 06:55:42 -05:00
|
|
|
newNode.toolkit.Custom = func() {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (Config.Options.Debug) {
|
2022-11-09 08:38:50 -06:00
|
|
|
log.Println("gui.Newutton() Button Clicked. Running custom() from outside toolkit START")
|
|
|
|
}
|
|
|
|
if (custom != nil) {
|
|
|
|
custom()
|
|
|
|
} else {
|
|
|
|
log.Println("wit/gui No callback function is defined for button name =", name)
|
2022-11-05 10:19:04 -05:00
|
|
|
}
|
|
|
|
if (Config.Options.Debug) {
|
2022-11-09 08:38:50 -06:00
|
|
|
log.Println("gui.NewButton() Button Clicked. Running custom() from outside toolkit END")
|
2022-11-05 10:19:04 -05:00
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
}
|
2021-10-31 14:21:36 -05:00
|
|
|
newNode.custom = custom
|
|
|
|
|
|
|
|
return newNode
|
|
|
|
}
|