2023-03-03 14:41:38 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
func (t *andlabsT) newCombobox(a *toolkit.Action) *andlabsT {
|
2023-03-03 14:41:38 -06:00
|
|
|
var newt andlabsT
|
2023-03-29 23:03:04 -05:00
|
|
|
w := a.Widget
|
2023-03-03 14:41:38 -06:00
|
|
|
log(debugToolkit, "newCombobox() START", w.Name)
|
|
|
|
|
|
|
|
newt.tw = w
|
2023-03-29 23:03:04 -05:00
|
|
|
newt.wId = a.WidgetId
|
|
|
|
newt.Type = w.Type
|
2023-03-03 14:41:38 -06:00
|
|
|
s := ui.NewEditableCombobox()
|
|
|
|
newt.uiEditableCombobox = s
|
2023-03-23 12:35:12 -05:00
|
|
|
newt.uiControl = s
|
2023-03-03 14:41:38 -06:00
|
|
|
|
|
|
|
// initialize the index
|
|
|
|
newt.c = 0
|
|
|
|
newt.val = make(map[int]string)
|
|
|
|
|
|
|
|
s.OnChanged(func(spin *ui.EditableCombobox) {
|
|
|
|
newt.tw.S = spin.Text()
|
2023-03-29 23:03:04 -05:00
|
|
|
newt.commonChange(newt.tw, a.WidgetId)
|
2023-03-03 14:41:38 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
return &newt
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *andlabsT) AddComboboxName(title string) {
|
|
|
|
t.uiEditableCombobox.Append(title)
|
|
|
|
if (t.val == nil) {
|
|
|
|
log(debugToolkit, "make map didn't work")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.val[t.c] = title
|
|
|
|
|
|
|
|
// If this is the first menu added, set the dropdown to it
|
|
|
|
// if (t.c == 0) {
|
|
|
|
// }
|
|
|
|
t.c = t.c + 1
|
|
|
|
}
|
|
|
|
|
2023-03-23 12:35:12 -05:00
|
|
|
func newCombobox(a *toolkit.Action) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugToolkit, "newCombobox()", a.Name)
|
2023-03-03 14:41:38 -06:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
t := andlabs[a.ParentId]
|
2023-03-03 14:41:38 -06:00
|
|
|
if (t == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugToolkit, "newCombobox() toolkit struct == nil. name=", a.Name)
|
2023-03-03 14:41:38 -06:00
|
|
|
listMap(debugToolkit)
|
|
|
|
return
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
newt := t.newCombobox(a)
|
2023-03-23 12:35:12 -05:00
|
|
|
place(a, t, newt)
|
2023-03-03 14:41:38 -06:00
|
|
|
}
|