summaryrefslogtreecommitdiff
path: root/button.go
blob: 2e2c7b4455e2154519412adbe958ae07555e3126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package gui

import "log"

func (n *Node) AddButton(name string, custom func(*Node)) *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)
	newNode.toolkit.Custom = func() {
		log.Println("gui.AppendButton() Button Clicked. Running custom()")
		custom(newNode)
	}
	newNode.custom = custom

	return newNode
}