@ -41,6 +41,7 @@ local Geom = require("ui/geometry")
local GestureRange = require ( " ui/gesturerange " )
local GestureRange = require ( " ui/gesturerange " )
local UIManager = require ( " ui/uimanager " )
local UIManager = require ( " ui/uimanager " )
local WidgetContainer = require ( " ui/widget/container/widgetcontainer " )
local WidgetContainer = require ( " ui/widget/container/widgetcontainer " )
local logger = require ( " logger " )
local Screen = Device.screen
local Screen = Device.screen
local _ = require ( " gettext " )
local _ = require ( " gettext " )
@ -304,41 +305,56 @@ end
-- [1] The most common implementation you'll see is a NOP for ReaderUI modules that defer gesture handling to ReaderUI.
-- [1] The most common implementation you'll see is a NOP for ReaderUI modules that defer gesture handling to ReaderUI.
-- Notification also implements a simple one to dismiss notifications on any user input,
-- Notification also implements a simple one to dismiss notifications on any user input,
-- which is something that doesn't impede our goal, which is why we don't need to deal with it.
-- which is something that doesn't impede our goal, which is why we don't need to deal with it.
function InputContainer : onIgnoreTouchInput ( toggle )
function InputContainer : setIgnoreTouchInput ( state )
local Notification = require ( " ui/widget/notification " )
logger.dbg ( " InputContainer:setIgnoreTouchInput " , state )
if toggle == false then
if state == true then
-- Replace the onGesture handler w/ the minimal one if that's not already the case
if not InputContainer._onGesture then
InputContainer._onGesture = InputContainer.onGesture
InputContainer.onGesture = InputContainer._onGestureFiltered
-- Notify UIManager so it knows what to do if a random popup shows up
UIManager._input_gestures_disabled = true
logger.dbg ( " Disabled InputContainer gesture handler " )
-- Notify our caller that the state changed
return true
end
elseif state == false then
-- Restore the proper onGesture handler if we disabled it
-- Restore the proper onGesture handler if we disabled it
if InputContainer._onGesture then
if InputContainer._onGesture then
InputContainer.onGesture = InputContainer._onGesture
InputContainer.onGesture = InputContainer._onGesture
InputContainer._onGesture = nil
InputContainer._onGesture = nil
Notification : notify ( " Restored touch input " )
UIManager._input_gestures_disabled = false
logger.dbg ( " Restored InputContainer gesture handler " )
return true
end
end
elseif toggle == true then
end
-- Replace the onGesture handler w/ the minimal one if that's not already the case
if not InputContainer._onGesture then
-- We did not actually change the state
InputContainer._onGesture = InputContainer.onGesture
return false
InputContainer.onGesture = InputContainer._onGestureFiltered
end
Notification : notify ( " Disabled touch input " )
-- And the matching Event handler
function InputContainer : onIgnoreTouchInput ( toggle )
local Notification = require ( " ui/widget/notification " )
if toggle == true then
if self : setIgnoreTouchInput ( true ) then
Notification : notify ( _ ( " Disabled touch input " ) )
end
elseif toggle == false then
if self : setIgnoreTouchInput ( false ) then
Notification : notify ( _ ( " Restored touch input " ) )
end
end
else
else
-- Toggle the current state
-- Toggle the current state
if InputContainer._onGesture then
return self : onIgnoreTouchInput ( not UIManager._input_gestures_disabled )
return self : onIgnoreTouchInput ( false )
else
return self : onIgnoreTouchInput ( true )
end
end
end
-- We only affect the base class, once is enough ;).
-- We only affect the base class, once is enough ;).
return true
return true
end
end
function InputContainer : onResume ( )
-- Always restore touch input on resume, to avoid confusion for scatter-brained users ;).
-- It's also helpful when the IgnoreTouchInput event is emitted by Dispatcher through other means than Gestures.
self : onIgnoreTouchInput ( false )
end
function InputContainer : onInput ( input , ignore_first_hold_release )
function InputContainer : onInput ( input , ignore_first_hold_release )
local InputDialog = require ( " ui/widget/inputdialog " )
local InputDialog = require ( " ui/widget/inputdialog " )
self.input_dialog = InputDialog : new {
self.input_dialog = InputDialog : new {