forked from mbk-lab/rui_orig
Fixed set of ListView checked property
This commit is contained in:
parent
b891986a67
commit
1e3c820c61
|
@ -36,6 +36,7 @@ GridLayout {
|
||||||
DropDownList { row = 7, column = 1, id = listCheckboxVAlign, current = 0, items = ["top", "bottom", "center"]},
|
DropDownList { row = 7, column = 1, id = listCheckboxVAlign, current = 0, items = ["top", "bottom", "center"]},
|
||||||
TextView { row = 8, text = "Checkbox horizontal align" },
|
TextView { row = 8, text = "Checkbox horizontal align" },
|
||||||
DropDownList { row = 8, column = 1, id = listCheckboxHAlign, current = 0, items = ["left", "right", "center"]},
|
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, "listView", rui.CheckboxHorizontalAlign, number)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
rui.Set(view, "listSetChecked", rui.ClickEvent, func() {
|
||||||
|
rui.Set(view, "listView", rui.Checked, "1, 4, 8")
|
||||||
|
})
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
12
listView.go
12
listView.go
|
@ -514,6 +514,18 @@ func (listView *listViewData) setChecked(value interface{}) bool {
|
||||||
checked = []int{}
|
checked = []int{}
|
||||||
} else {
|
} else {
|
||||||
switch value := value.(type) {
|
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:
|
case int:
|
||||||
checked = []int{value}
|
checked = []int{value}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue