summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-26 22:21:40 +0800
committerruki <[email protected]>2018-01-26 08:10:04 +0800
commitee7c1f8452c0e0b819ea9b896fd58a2268832ca6 (patch)
tree7f29a3a5b48d2871e4eda6ac6f668c4fafa1e6a5
parent1589248c258456d5045d8e5bb9db69c9663f7181 (diff)
disable multi-line for mconfdialog input
-rw-r--r--xmake/core/ui/inputdialog.lua2
-rw-r--r--xmake/core/ui/mconfdialog.lua1
-rw-r--r--xmake/core/ui/textedit.lua5
3 files changed, 6 insertions, 2 deletions
diff --git a/xmake/core/ui/inputdialog.lua b/xmake/core/ui/inputdialog.lua
index 511a9c810..7e246ef3e 100644
--- a/xmake/core/ui/inputdialog.lua
+++ b/xmake/core/ui/inputdialog.lua
@@ -54,7 +54,7 @@ function inputdialog:init(name, bounds, title)
-- text changed
self:text():action_set(action.ac_on_text_changed, function (v)
if v:text() then
- local lines = #self:text():splitext(v:text())
+ local lines = #self:text():splitext(v:text()) + 1
if lines > 0 and lines < self:height() then
self:text():bounds().ey = lines
self:textedit():bounds().sy = lines
diff --git a/xmake/core/ui/mconfdialog.lua b/xmake/core/ui/mconfdialog.lua
index 8a6869862..f27d9de51 100644
--- a/xmake/core/ui/mconfdialog.lua
+++ b/xmake/core/ui/mconfdialog.lua
@@ -65,6 +65,7 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> to go back or exit, <?> for Hel
local dialog_input = inputdialog:new("dialog.input", rect {0, 0, math.min(80, self:width()), math.min(8, self:height())}, "input dialog")
dialog_input:background_set(self:frame():background())
dialog_input:frame():background_set("cyan")
+ dialog_input:textedit():option_set("multiline", false)
dialog_input:button_add("ok", "< Ok >", function (v)
local config = dialog_input:extra("config")
if config.kind == "string" then
diff --git a/xmake/core/ui/textedit.lua b/xmake/core/ui/textedit.lua
index 4bc941855..ea5222140 100644
--- a/xmake/core/ui/textedit.lua
+++ b/xmake/core/ui/textedit.lua
@@ -48,6 +48,9 @@ function textedit:init(name, bounds, text)
-- disable progress
self:option_set("progress", false)
+
+ -- enable multiple line
+ self:option_set("multiline", true)
end
-- draw textedit
@@ -79,7 +82,7 @@ function textedit:event_on(e)
if e.key_code > 0x1f and e.key_code < 0x7f then
self:text_set(self:text() .. e.key_name)
return true
- elseif e.key_name == "Enter" then
+ elseif e.key_name == "Enter" and self:option("multiline") then
self:text_set(self:text() .. '\n')
return true
elseif e.key_name == "Backspace" then