From 6aeecdba08899c13ce9cc86847e6d8a84f154654 Mon Sep 17 00:00:00 2001 From: Cosmin Gorgovan Date: Thu, 30 Mar 2017 23:32:01 +0100 Subject: [PATCH] Only show the last character of a password after typing it --- frontend/ui/widget/inputtext.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index 7243ea4ac..0ed6a9323 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -71,7 +71,7 @@ function InputText:init() self:initEventListener() end -function InputText:initTextBox(text) +function InputText:initTextBox(text, char_added) self.text = text local fgcolor local show_charlist @@ -87,8 +87,10 @@ function InputText:initTextBox(text) if self.text_type == "password" then show_text = self.text:gsub( "(.-).", function() return "*" end) - show_text = show_text:gsub( - "(.)$", function() return self.text:sub(-1) end) + if char_added then + show_text = show_text:gsub( + "(.)$", function() return self.text:sub(-1) end) + end end self.charlist = util.splitToChars(text) if self.charpos == nil then @@ -176,7 +178,7 @@ function InputText:addChar(char) end table.insert(self.charlist, self.charpos, char) self.charpos = self.charpos + 1 - self:initTextBox(table.concat(self.charlist)) + self:initTextBox(table.concat(self.charlist), true) end function InputText:delChar()