forked from mbk-lab/rui_orig
2
0
Fork 0

Fixed set of ListView checked property

This commit is contained in:
Alexei Anoshenko 2022-04-05 18:50:48 +03:00
parent b891986a67
commit 1e3c820c61
2 changed files with 17 additions and 0 deletions

View File

@ -36,6 +36,7 @@ GridLayout {
DropDownList { row = 7, column = 1, id = listCheckboxVAlign, current = 0, items = ["top", "bottom", "center"]},
TextView { row = 8, text = "Checkbox horizontal align" },
DropDownList { row = 8, column = 1, id = listCheckboxHAlign, current = 0, items = ["left", "right", "center"]},
Button { row = 9, column = 0:1, id = listSetChecked, content = "set checked 1,4,8" }
]
}
]
@ -91,5 +92,9 @@ func createListViewDemo(session rui.Session) rui.View {
rui.Set(view, "listView", rui.CheckboxHorizontalAlign, number)
})
rui.Set(view, "listSetChecked", rui.ClickEvent, func() {
rui.Set(view, "listView", rui.Checked, "1, 4, 8")
})
return view
}

View File

@ -514,6 +514,18 @@ func (listView *listViewData) setChecked(value interface{}) bool {
checked = []int{}
} else {
switch value := value.(type) {
case string:
checked = []int{}
for _, val := range strings.Split(value, ",") {
n, err := strconv.Atoi(strings.Trim(val, " \t"))
if err != nil {
invalidPropertyValue(Checked, value)
ErrorLog(err.Error())
return false
}
checked = append(checked, n)
}
case int:
checked = []int{value}