improve button/on_click

This commit is contained in:
ruki
2020-11-21 00:35:47 +08:00
parent 00b35c523c
commit ec90d4a2a7
3 changed files with 12 additions and 6 deletions

View File

@@ -45,10 +45,6 @@ function button:init(name, bounds, text, on_action)
self:option_set("mouseable", true)
self:action_set(action.ac_on_enter, on_action)
self:action_set(action.ac_on_clicked, function (v)
-- FIXME
if v:parent()._do_select then
v:parent():_do_select()
end
v:action_on(action.ac_on_enter)
return true
end)

View File

@@ -87,7 +87,12 @@ function choicebox:_do_insert(value, index, selected)
local text = (selected and "(X) " or "( ) ") .. tostring(value)
-- init a value item view
local item = button:new("choicebox.value." .. self:count(), rect:new(0, self:count(), self:width(), 1), text)
local item = button:new("choicebox.value." .. self:count(),
rect:new(0, self:count(), self:width(), 1),
text,
function (v, e)
self:_do_select()
end)
-- attach this index
item:extra_set("index", index)

View File

@@ -118,7 +118,12 @@ end
function menuconf:_do_insert(config)
-- init a config item view
local item = button:new("menuconf.config." .. self:count(), rect:new(0, self:count(), self:width(), 1), tostring(config))
local item = button:new("menuconf.config." .. self:count(),
rect:new(0, self:count(), self:width(), 1),
tostring(config),
function (v, e)
self:_do_select()
end)
-- attach this config
item:extra_set("config", config)