summaryrefslogtreecommitdiff
path: root/button.go
blob: c9b59050aacb2e5b99e93d66b399ddd09ad98b09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package gui

import "go.wit.com/gui/toolkit"

func (parent *Node) NewButton(name string, custom func()) *Node {
	newNode := parent.newNode(name, toolkit.Button)
	newNode.Custom = custom

	a := newAction(newNode, toolkit.Add)
	sendAction(a)
	return newNode
}

// 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
}