diff options
| author | ruki <[email protected]> | 2018-01-26 00:45:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-25 22:31:14 +0800 |
| commit | 7d775a7dc5dc064c629e63a7e06249cebbfc8e11 (patch) | |
| tree | b1635ce647ee9678a42d8c0431d79ae7700627d9 | |
| parent | 2a0884e05eea1f1c274d52d4922485513b97e3e2 (diff) | |
select boolean config
| -rw-r--r-- | xmake/core/ui/menuconf.lua | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/xmake/core/ui/menuconf.lua b/xmake/core/ui/menuconf.lua index f749a23e6..ca4c772d6 100644 --- a/xmake/core/ui/menuconf.lua +++ b/xmake/core/ui/menuconf.lua @@ -100,12 +100,23 @@ end -- do select the current config function menuconf:_do_select() - -- TODO - + -- get the current item + local item = self:current() + -- get the current config - local config = self:current() - if self:current() then - config = self:current():extra("config") + local config = item:extra("config") + + -- get value + local value = config.value + if value == nil then + value = config.default + end + + -- select the boolean config + if config.kind == "boolean" then + config.new = false + config.value = not value + item:text_set(tostring(config)) end -- do action: on selected @@ -148,8 +159,11 @@ function config:__tostring() end -- get value - local value = self.value or self.default - + local value = self.value + if value == nil then + value = self.default + end + -- update text if self.kind == "boolean" or (not self.kind and type(value) == "boolean") then -- boolean config? text = (value and "[*] " or "[ ] ") .. text |
