summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/checkbox.go
blob: d60b515653818a7a5a0810b99db4ee739405054e (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
package main

import (
	"git.wit.org/wit/gui/toolkit"
	"github.com/andlabs/ui"
	_ "github.com/andlabs/ui/winmanifest"
)

func (t *andlabsT) newCheckbox(a *toolkit.Action) *andlabsT {
	var newt andlabsT
	log(debugToolkit, "newCheckbox()", a.Name, a.WidgetType)
	newt.WidgetType = a.WidgetType
	newt.wId = a.WidgetId
	newt.Name = a.Name
	newt.Text = a.Text

	newt.uiCheckbox = ui.NewCheckbox(a.Text)
	newt.uiControl = newt.uiCheckbox

	newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) {
		newt.b = newt.checked()
		log(debugChange, "val =", newt.b)
		newt.doUserEvent()
	})

	return &newt
}

func (t *andlabsT) checked() bool {
	return t.uiCheckbox.Checked()
}

func newCheckbox(a *toolkit.Action) {
	log(debugToolkit, "newCheckbox()", a.Name)

	t := andlabs[a.ParentId]
	if (t == nil) {
		listMap(debugError)
		return
	}
	newt := t.newCheckbox(a)
	place(a, t, newt)
}