From 25b40fd1b692f86651a0da3aa0b76884889c459b Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sun, 11 Apr 2021 01:08:29 +0300 Subject: [PATCH] Input dialogs: do not allow blank input cont'd (#7516) --- frontend/ui/widget/container/inputcontainer.lua | 1 + frontend/ui/widget/keyvaluepage.lua | 1 + frontend/ui/widget/menu.lua | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/container/inputcontainer.lua b/frontend/ui/widget/container/inputcontainer.lua index 8ec0375cf..03be5c89a 100644 --- a/frontend/ui/widget/container/inputcontainer.lua +++ b/frontend/ui/widget/container/inputcontainer.lua @@ -287,6 +287,7 @@ function InputContainer:onInput(input, ignore_first_hold_release) text = input.ok_text or _("OK"), is_enter_default = true, callback = function() + if input.deny_blank_input and self.input_dialog:getInputText() == "" then return end input.callback(self.input_dialog:getInputText()) self:closeInputDialog() end, diff --git a/frontend/ui/widget/keyvaluepage.lua b/frontend/ui/widget/keyvaluepage.lua index 2bfc5ee9d..d474d48df 100644 --- a/frontend/ui/widget/keyvaluepage.lua +++ b/frontend/ui/widget/keyvaluepage.lua @@ -433,6 +433,7 @@ function KeyValuePage:init() hint_func = function() return "(" .. "1 - " .. self.pages .. ")" end, + deny_blank_input = true, callback = function(input) local page = tonumber(input) if page and page >= 1 and page <= self.pages then diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index 84584c107..6b64e8249 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -733,8 +733,8 @@ function Menu:init() local page = tonumber(self.page_info_text.input_dialog:getInputText()) if page and page >= 1 and page <= self.page_num then self:onGotoPage(page) + self.page_info_text:closeInputDialog() end - self.page_info_text:closeInputDialog() end, }, }, @@ -754,6 +754,7 @@ function Menu:init() --- @todo Support utf8 lowercase. local filename = FFIUtil.basename(v.path):lower() local search_string = self.page_info_text.input_dialog:getInputText():lower() + if search_string == "" then return end local i, _ = filename:find(search_string) if i == 1 and not v.is_go_up then self:onGotoPage(math.ceil(k / self.perpage))