InputDialog: tap outside to close dialog if keyboard is hidden (#11094)

pull/11088/merge
hius07 6 months ago committed by GitHub
parent 082ef9b545
commit da8e23c011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -484,6 +484,7 @@ function ReaderHandMade:addOrEditPageTocItem(pageno, when_updated_callback, sele
{ {
{ {
text = _("Cancel"), text = _("Cancel"),
id = "close",
callback = function() callback = function()
UIManager:close(dialog) UIManager:close(dialog)
end, end,

@ -267,16 +267,18 @@ function ButtonDialog:onCloseWidget()
end) end)
end end
function ButtonDialog:onTapClose() function ButtonDialog:onClose()
UIManager:close(self)
if self.tap_close_callback then if self.tap_close_callback then
self.tap_close_callback() self.tap_close_callback()
end end
UIManager:close(self)
return true return true
end end
function ButtonDialog:onClose() function ButtonDialog:onTapClose(arg, ges)
self:onTapClose() if ges.pos:notIntersectWith(self.movable.dimen) then
self:onClose()
end
return true return true
end end

@ -436,7 +436,10 @@ function InputDialog:init()
self.ges_events.Tap = { self.ges_events.Tap = {
GestureRange:new{ GestureRange:new{
ges = "tap", ges = "tap",
range = self[1].dimen, -- screen above the keyboard range = Geom:new{
w = self.screen_width,
h = self.screen_height,
},
}, },
} }
end end
@ -478,13 +481,20 @@ function InputDialog:getAddedWidgetAvailableWidth()
return self._input_widget.width return self._input_widget.width
end end
-- Close the keyboard if we tap anywhere outside of the keyboard (that isn't an input field, where it would be caught via InputText:onTapTextBox) -- Tap outside of inputbox to hide the keyboard (inside the inputbox it is caught via InputText:onTapTextBox).
function InputDialog:onTap() -- If the keyboard is hidden, tap outside of the dialog to close the dialog.
function InputDialog:onTap(arg, ges)
-- This is slightly more fine-grained than VK's own visibility lock, hence the duplication... -- This is slightly more fine-grained than VK's own visibility lock, hence the duplication...
if self.deny_keyboard_hiding then if self.deny_keyboard_hiding then
return return
end end
self:onCloseKeyboard() if self:isKeyboardVisible() then
self:onCloseKeyboard()
else
if ges.pos:notIntersectWith(self.dialog_frame.dimen) then
self:onCloseDialog()
end
end
end end
function InputDialog:getInputText() function InputDialog:getInputText()

@ -724,6 +724,7 @@ function Menu:init()
{ {
{ {
text = _("Cancel"), text = _("Cancel"),
id = "close",
callback = function() callback = function()
self.page_info_text:closeInputDialog() self.page_info_text:closeInputDialog()
end, end,

@ -441,6 +441,7 @@ function TextViewer:findDialog()
{ {
{ {
text = _("Cancel"), text = _("Cancel"),
id = "close",
callback = function() callback = function()
UIManager:close(input_dialog) UIManager:close(input_dialog)
end, end,

Loading…
Cancel
Save