From 976aaf5f5319af1430f8c3853816011e18015f48 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 13 Aug 2023 06:38:45 +0200 Subject: [PATCH] InputText: Actually flip the is_keyboard_hidden flag properly MultiInputDialog does a close -> show in the same callback, so if we don't actually keep it in sync with the actual state, we lose the keyboard and essentially softlock the UI, which is Very Bad(TM). NOTE: InputDialog has its own keyboard_hidden flag, and it looks... fairly nightmarish. --- frontend/ui/widget/inputtext.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index 707ffab8f..4726e601a 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -64,7 +64,7 @@ local InputText = InputContainer:extend{ for_measurement_only = nil, -- When the widget is a one-off used to compute text height do_select = false, -- to start text selection selection_start_pos = nil, -- selection start position - is_keyboard_hidden = false, -- to be able to show the keyboard again when it was hidden + is_keyboard_hidden = true, -- to be able to show the keyboard again when it was hidden. (On init, it's the caller's responsibility to call onShowKeyboard, as far as we're concerned, it's hidden) } -- These may be (internally) overloaded as needed, depending on Device capabilities. @@ -132,9 +132,8 @@ local function initTouchEvents() if self.parent.onSwitchFocus then self.parent:onSwitchFocus(self) else - if self.is_keyboard_hidden == true then + if self.is_keyboard_hidden then self:onShowKeyboard() - self.is_keyboard_hidden = false end end -- zh keyboard with candidates shown here has _frame_textwidget.dimen = nil. @@ -677,8 +676,12 @@ dbg:guard(InputText, "onTextInput", function InputText:onShowKeyboard(ignore_first_hold_release) Device:startTextInput() - self.keyboard.ignore_first_hold_release = ignore_first_hold_release - UIManager:show(self.keyboard) + + if self.is_keyboard_hidden then + self.keyboard.ignore_first_hold_release = ignore_first_hold_release + UIManager:show(self.keyboard) + self.is_keyboard_hidden = false + end return true end