improve button/on_click
This commit is contained in:
@@ -45,10 +45,6 @@ function button:init(name, bounds, text, on_action)
|
|||||||
self:option_set("mouseable", true)
|
self:option_set("mouseable", true)
|
||||||
self:action_set(action.ac_on_enter, on_action)
|
self:action_set(action.ac_on_enter, on_action)
|
||||||
self:action_set(action.ac_on_clicked, function (v)
|
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)
|
v:action_on(action.ac_on_enter)
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
|
@@ -87,7 +87,12 @@ function choicebox:_do_insert(value, index, selected)
|
|||||||
local text = (selected and "(X) " or "( ) ") .. tostring(value)
|
local text = (selected and "(X) " or "( ) ") .. tostring(value)
|
||||||
|
|
||||||
-- init a value item view
|
-- 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
|
-- attach this index
|
||||||
item:extra_set("index", index)
|
item:extra_set("index", index)
|
||||||
|
@@ -118,7 +118,12 @@ end
|
|||||||
function menuconf:_do_insert(config)
|
function menuconf:_do_insert(config)
|
||||||
|
|
||||||
-- init a config item view
|
-- 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
|
-- attach this config
|
||||||
item:extra_set("config", config)
|
item:extra_set("config", config)
|
||||||
|
Reference in New Issue
Block a user