Change gui.widgets.List:setChoices to keep state in internal table

Fixes #1171
develop
Pauli 2018-06-20 17:23:57 +03:00
parent 2c106fa7a5
commit ed23d2c4e2
1 changed files with 8 additions and 6 deletions

@ -456,15 +456,17 @@ function List:init(info)
end end
function List:setChoices(choices, selected) function List:setChoices(choices, selected)
self.choices = choices or {} self.choices = {}
for i,v in ipairs(self.choices) do for i,v in ipairs(choices) do
local l = utils.clone(v);
if type(v) ~= 'table' then if type(v) ~= 'table' then
v = { text = v } l = { text = v }
self.choices[i] = v else
l.text = v.text or v.caption or v[1]
end end
v.text = v.text or v.caption or v[1] parse_label_text(l)
parse_label_text(v) self.choices[i] = l
end end
self:setSelected(selected) self:setSelected(selected)