summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-26 22:27:47 +0800
committerruki <[email protected]>2018-01-26 08:46:46 +0800
commitba6283f21c9318c886dabf5a4b87df3a7a1b6ce8 (patch)
tree8a446b5707279071c790b45c8ce343920d3b67e3
parentee7c1f8452c0e0b819ea9b896fd58a2268832ca6 (diff)
add number input dialog
-rw-r--r--xmake/core/ui/border.lua5
-rw-r--r--xmake/core/ui/mconfdialog.lua12
2 files changed, 14 insertions, 3 deletions
diff --git a/xmake/core/ui/border.lua b/xmake/core/ui/border.lua
index 6ed001db4..d8f810bc2 100644
--- a/xmake/core/ui/border.lua
+++ b/xmake/core/ui/border.lua
@@ -99,6 +99,11 @@ function border:cornerattr_set(attr_ul, attr_rl)
self:invalidate()
end
+-- swap border corner attribute
+function border:cornerattr_swap()
+ local cornerattr = self:cornerattr()
+ self:cornerattr_set(cornerattr[2], cornerattr[1])
+end
-- return module
return border
diff --git a/xmake/core/ui/mconfdialog.lua b/xmake/core/ui/mconfdialog.lua
index f27d9de51..b02eb17ea 100644
--- a/xmake/core/ui/mconfdialog.lua
+++ b/xmake/core/ui/mconfdialog.lua
@@ -70,6 +70,8 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> to go back or exit, <?> for Hel
local config = dialog_input:extra("config")
if config.kind == "string" then
config.value = dialog_input:textedit():text()
+ elseif config.kind == "number" then
+ config.value = tonumber(dialog_input:textedit():text())
end
dialog_input:quit()
end)
@@ -80,11 +82,15 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> to go back or exit, <?> for Hel
-- on selected
self:menuconf():action_set(action.ac_on_selected, function (v, config)
- if config.kind == "string" then
+ if config.kind == "string" or config.kind == "number" then
dialog_input:extra_set("config", config)
dialog_input:title():text_set(config:prompt())
- dialog_input:textedit():text_set(config.value)
- dialog_input:text():text_set("Please enter a string value. Use the <TAB> key to move from the input fields to buttons below it.")
+ dialog_input:textedit():text_set(tostring(config.value))
+ if config.kind == "string" then
+ dialog_input:text():text_set("Please enter a string value. Use the <TAB> key to move from the input fields to buttons below it.")
+ else
+ dialog_input:text():text_set("Please enter a decimal value. Fractions will not be accepted. Use the <TAB> key to move from the input field to the buttons below it.")
+ end
self:insert(dialog_input, {centerx = true, centery = true})
end
end)