summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-26 22:40:25 +0800
committerruki <[email protected]>2018-01-26 10:02:35 +0800
commitb58b0d43b32aae6f084659fc80aeb048e95df71e (patch)
treeec32e3144b324b3da1e6b34e92e0eeb00b783e90
parent19e82986fb67b09726905788b53c8ad8ad05c263 (diff)
modify choice value
-rw-r--r--xmake/core/ui/choicedialog.lua1
-rw-r--r--xmake/core/ui/mconfdialog.lua5
-rw-r--r--xmake/core/ui/menuconf.lua8
3 files changed, 8 insertions, 6 deletions
diff --git a/xmake/core/ui/choicedialog.lua b/xmake/core/ui/choicedialog.lua
index 580345487..cd4a42e06 100644
--- a/xmake/core/ui/choicedialog.lua
+++ b/xmake/core/ui/choicedialog.lua
@@ -49,7 +49,6 @@ function choicedialog:init(name, bounds, title)
self:choicebox():event_on(event.command {"cm_enter"})
self:quit()
end)
- self:button_add("help", "< Help >", function (v, e) end)
self:buttons():select(self:button("select"))
-- insert choice box
diff --git a/xmake/core/ui/mconfdialog.lua b/xmake/core/ui/mconfdialog.lua
index 7f05aa5ba..ce5f63949 100644
--- a/xmake/core/ui/mconfdialog.lua
+++ b/xmake/core/ui/mconfdialog.lua
@@ -89,6 +89,9 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> to go back or exit, <?> for Hel
dialog_choice:background_set(self:frame():background())
dialog_choice:frame():background_set("cyan")
dialog_choice:box():frame():background_set("cyan")
+ dialog_choice:choicebox():action_set(action.ac_on_selected, function (v, value)
+ -- TODO
+ end)
-- on selected
self:menuconf():action_set(action.ac_on_selected, function (v, config)
@@ -108,7 +111,7 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> to go back or exit, <?> for Hel
-- show choice dialog
elseif config.kind == "choice" then
dialog_choice:title():text_set(config:prompt())
- dialog_choice:choicebox():load(config.values, 1)
+ dialog_choice:choicebox():load(config.values, config.value)
self:insert(dialog_choice, {centerx = true, centery = true})
end
end)
diff --git a/xmake/core/ui/menuconf.lua b/xmake/core/ui/menuconf.lua
index 370f59247..50395452c 100644
--- a/xmake/core/ui/menuconf.lua
+++ b/xmake/core/ui/menuconf.lua
@@ -142,8 +142,8 @@ end
-- string config
-- - {name = "...", kind = "string", value = "xmake", default = "", description = "string config item", new = true/false}
--
--- choice config
--- - {name = "...", kind = "choice", value = "...", default = "...", description = "choice config item", values = {1, 2, 3, 4, 5}}
+-- choice config (value is index)
+-- - {name = "...", kind = "choice", value = 1, default = 1, description = "choice config item", values = {2, 2, 3, 4, 5}}
--
-- menu config
-- - {name = "...", kind = "menu", description = "menu config item", configs = {...}}
@@ -200,7 +200,7 @@ function config:__tostring()
elseif self.kind == "string" or (not self.kind and type(value) == "string") then -- string config?
text = "(" .. tostring(value or "") .. ") " .. text
elseif self.kind == "choice" then -- choice config?
- text = " " .. text .. " (" .. tostring(value or "") .. ")" .. " --->"
+ text = " " .. text .. " (" .. tostring(self.values[value or 1]) .. ")" .. " --->"
elseif self.kind == "menu" then -- menu config?
text = " " .. text .. " --->"
end
@@ -219,7 +219,7 @@ menuconf.config = menuconf.config or config
menuconf.menu = menuconf.menu or config { kind = "menu", configs = {} }
menuconf.number = menuconf.number or config { kind = "number", default = 0 }
menuconf.string = menuconf.string or config { kind = "string", default = "" }
-menuconf.choice = menuconf.choice or config { kind = "choice", values = {} }
+menuconf.choice = menuconf.choice or config { kind = "choice", default = 1, values = {} }
menuconf.boolean = menuconf.boolean or config { kind = "boolean", default = false }
-- return module