new-gui/button.go

24 lines
706 B
Go

package gui
import "log"
func (n *Node) NewButton(name string, custom func()) *Node {
if (n.toolkit == nil) {
log.Println("gui.Node.AppendButton() filed node.toolkit == nil")
panic("gui.Node.AppendButton() filed node.toolkit == nil")
return n
}
newNode := n.New(name)
newNode.toolkit = n.toolkit.NewButton(name)
// TODO: this is still confusing and probably wrong. This needs to communicate through a channel
newNode.toolkit.Custom = func() {
log.Println("gui.AppendButton() Button Clicked. Running custom() from outside toolkit START")
custom()
log.Println("gui.AppendButton() Button Clicked. Running custom() from outside toolkit END")
}
newNode.custom = custom
return newNode
}