2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
)
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
func (t *andlabsT) newCheckbox(a *toolkit.Action) *andlabsT {
|
2022-11-14 14:30:28 -06:00
|
|
|
var newt andlabsT
|
2023-03-29 23:03:04 -05:00
|
|
|
w := a.Widget
|
2023-04-03 10:26:47 -05:00
|
|
|
log(debugToolkit, "newCheckbox()", a.Name, a.WidgetType)
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.tw = w
|
2023-04-03 10:26:47 -05:00
|
|
|
newt.WidgetType = a.WidgetType
|
2023-03-29 23:03:04 -05:00
|
|
|
newt.wId = a.WidgetId
|
2023-04-03 10:26:47 -05:00
|
|
|
newt.Name = a.Name
|
|
|
|
newt.Text = a.Text
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-04-03 10:26:47 -05:00
|
|
|
newt.uiCheckbox = ui.NewCheckbox(a.Text)
|
2023-03-23 12:35:12 -05:00
|
|
|
newt.uiControl = newt.uiCheckbox
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) {
|
|
|
|
newt.tw.B = newt.checked()
|
2023-03-01 11:35:36 -06:00
|
|
|
log(debugChange, "val =", newt.tw.B)
|
2023-03-29 23:03:04 -05:00
|
|
|
newt.commonChange(newt.tw, a.WidgetId)
|
2022-10-21 11:40:08 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
return &newt
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
func (t *andlabsT) checked() bool {
|
2022-10-21 11:40:08 -05:00
|
|
|
return t.uiCheckbox.Checked()
|
|
|
|
}
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-23 12:35:12 -05:00
|
|
|
func newCheckbox(a *toolkit.Action) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugToolkit, "newCheckbox()", a.Name)
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
t := andlabs[a.ParentId]
|
2023-02-25 14:05:25 -06:00
|
|
|
if (t == nil) {
|
2023-03-01 11:35:36 -06:00
|
|
|
listMap(debugError)
|
|
|
|
return
|
2023-02-25 14:05:25 -06:00
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
newt := t.newCheckbox(a)
|
2023-03-23 12:35:12 -05:00
|
|
|
place(a, t, newt)
|
2023-03-01 11:35:36 -06:00
|
|
|
}
|