summaryrefslogtreecommitdiff
path: root/demo-window.go
blob: 12cbe73cdafacd3ba5d883f1e551f7e91b926b3b (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package gui

import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"

var mybox *ui.Box

func (n *Node) AddGroup(title string) *Node {
	hbox := n.uiBox
	if (hbox == nil) {
		return n
	}
	group := ui.NewGroup(title)
	group.SetMargined(true)
	hbox.Append(group, true)

	vbox := ui.NewVerticalBox()
	vbox.SetPadded(true)
	group.SetChild(vbox)

	newNode := n.AddNode(title)
	newNode.uiBox = vbox
	return newNode
}

func (n *Node) GetText(name string) string {
	if (n.uiText != nil) {
		return n.uiText.Text()
	}
	return n.Name
}

func (n *Node) AddComboBox(title string, s ...string) *Node {
	box := n.uiBox
	if (box == nil) {
		return n
	}

	ecbox := ui.NewEditableCombobox()

	for id, name := range s {
		log.Println("Adding Combobox Entry:", id, name)
		ecbox.Append(name)
	}

	ecbox.OnChanged(func(*ui.EditableCombobox) {
		test := ecbox.Text()
		log.Println("text is now:", test)
	})

	box.Append(ecbox, false)

	newNode := n.AddNode(title)
	newNode.uiText = ecbox
	return newNode
}