mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Cleanup: Remove unused onAnyKeyPressed handlers
And simplify the few we do catch by using aliases instead of duplicated functions;).
This commit is contained in:
@@ -432,11 +432,6 @@ function DateTimeWidget:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function DateTimeWidget:onAnyKeyPressed()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function DateTimeWidget:onTapClose(arg, ges_ev)
|
||||
if ges_ev.pos:notIntersectWith(self.date_frame.dimen) then
|
||||
self:onClose()
|
||||
|
||||
@@ -337,11 +337,6 @@ function DoubleSpinWidget:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function DoubleSpinWidget:onAnyKeyPressed()
|
||||
self:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function DoubleSpinWidget:onTapClose(arg, ges_ev)
|
||||
if ges_ev.pos:notIntersectWith(self.widget_frame.dimen) then
|
||||
self:onClose()
|
||||
|
||||
@@ -539,11 +539,6 @@ function FrontLightWidget:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function FrontLightWidget:onAnyKeyPressed()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function FrontLightWidget:onClose()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
|
||||
@@ -816,11 +816,6 @@ function ImageViewer:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function ImageViewer:onAnyKeyPressed()
|
||||
self:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function ImageViewer:onCloseWidget()
|
||||
-- Our ImageWidget (self._image_wg) is always a proper child widget, so it'll receive this event,
|
||||
-- and attempt to free its resources accordingly.
|
||||
|
||||
@@ -280,18 +280,12 @@ function InfoMessage:dismiss()
|
||||
UIManager:close(self)
|
||||
end
|
||||
|
||||
function InfoMessage:onAnyKeyPressed()
|
||||
self:dismiss()
|
||||
if self.readonly ~= true then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function InfoMessage:onTapClose()
|
||||
self:dismiss()
|
||||
if self.readonly ~= true then
|
||||
return true
|
||||
end
|
||||
end
|
||||
InfoMessage.onAnyKeyPressed = InfoMessage.onTapClose
|
||||
|
||||
return InfoMessage
|
||||
|
||||
@@ -199,17 +199,13 @@ function Notification:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function Notification:onAnyKeyPressed()
|
||||
if self.toast then return end -- should not happen
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function Notification:onTapClose()
|
||||
if self.toast then return end -- should not happen
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
Notification.onAnyKeyPressed = Notification.onTapClose
|
||||
|
||||
-- Toasts should go bye-bye on user input, without stopping the event's propagation.
|
||||
function Notification:onKeyPress(key)
|
||||
|
||||
@@ -99,15 +99,10 @@ function QRMessage:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function QRMessage:onAnyKeyPressed()
|
||||
-- triggered by our defined key events
|
||||
self.dismiss_callback()
|
||||
UIManager:close(self)
|
||||
end
|
||||
|
||||
function QRMessage:onTapClose()
|
||||
self.dismiss_callback()
|
||||
UIManager:close(self)
|
||||
end
|
||||
QRMessage.onAnyKeyPressed = QRMessage.onTapClose
|
||||
|
||||
return QRMessage
|
||||
|
||||
@@ -218,11 +218,6 @@ function RadioButtonWidget:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function RadioButtonWidget:onAnyKeyPressed()
|
||||
self:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function RadioButtonWidget:onTapClose(arg, ges_ev)
|
||||
if ges_ev.pos:notIntersectWith(self.widget_frame.dimen) then
|
||||
self:onClose()
|
||||
|
||||
@@ -372,11 +372,6 @@ function SkimToWidget:goToByEvent(event_name)
|
||||
end
|
||||
end
|
||||
|
||||
function SkimToWidget:onAnyKeyPressed()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function SkimToWidget:onFirstRowKeyPress(percent)
|
||||
local page = Math.round(percent * self.page_count)
|
||||
self:addOriginToLocationStack()
|
||||
|
||||
@@ -293,11 +293,6 @@ function SpinWidget:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function SpinWidget:onAnyKeyPressed()
|
||||
self:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function SpinWidget:onTapClose(arg, ges_ev)
|
||||
if ges_ev.pos:notIntersectWith(self.spin_frame.dimen) then
|
||||
self:onClose()
|
||||
|
||||
@@ -289,11 +289,6 @@ function TextViewer:onShow()
|
||||
return true
|
||||
end
|
||||
|
||||
function TextViewer:onAnyKeyPressed()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function TextViewer:onTapClose(arg, ges_ev)
|
||||
if ges_ev.pos:notIntersectWith(self.frame.dimen) then
|
||||
self:onClose()
|
||||
|
||||
@@ -108,7 +108,7 @@ function TrapWidget:init()
|
||||
end
|
||||
end
|
||||
|
||||
function TrapWidget:_dismissAndResent(evtype, ev)
|
||||
function TrapWidget:_dismissAndResend(evtype, ev)
|
||||
self.dismiss_callback()
|
||||
UIManager:close(self)
|
||||
if self.resend_event and evtype and ev then
|
||||
@@ -125,19 +125,19 @@ function TrapWidget:_dismissAndResent(evtype, ev)
|
||||
end
|
||||
|
||||
function TrapWidget:onAnyKeyPressed(_, ev)
|
||||
return self:_dismissAndResent("KeyPress", ev)
|
||||
return self:_dismissAndResend("KeyPress", ev)
|
||||
end
|
||||
|
||||
function TrapWidget:onTapDismiss(_, ev)
|
||||
return self:_dismissAndResent("Gesture", ev)
|
||||
return self:_dismissAndResend("Gesture", ev)
|
||||
end
|
||||
|
||||
function TrapWidget:onHoldDismiss(_, ev)
|
||||
return self:_dismissAndResent("Gesture", ev)
|
||||
return self:_dismissAndResend("Gesture", ev)
|
||||
end
|
||||
|
||||
function TrapWidget:onSwipeDismiss(_, ev)
|
||||
return self:_dismissAndResent("Gesture", ev)
|
||||
return self:_dismissAndResend("Gesture", ev)
|
||||
end
|
||||
|
||||
function TrapWidget:onShow()
|
||||
|
||||
@@ -479,10 +479,6 @@ function ReaderProgress:genSummaryWeek(width)
|
||||
}
|
||||
end
|
||||
|
||||
function ReaderProgress:onAnyKeyPressed()
|
||||
return self:onClose()
|
||||
end
|
||||
|
||||
function ReaderProgress:onSwipe(arg, ges_ev)
|
||||
if ges_ev.direction == "south" then
|
||||
-- Allow easier closing with swipe up/down
|
||||
@@ -499,17 +495,15 @@ function ReaderProgress:onSwipe(arg, ges_ev)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderProgress:onMultiSwipe(arg, ges_ev)
|
||||
-- For consistency with other fullscreen widgets where swipe south can't be
|
||||
-- used to close and where we then allow any multiswipe to close, allow any
|
||||
-- multiswipe to close this widget too.
|
||||
self:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderProgress:onClose()
|
||||
UIManager:close(self)
|
||||
return true
|
||||
end
|
||||
ReaderProgress.onAnyKeyPressed = ReaderProgress.onClose
|
||||
-- For consistency with other fullscreen widgets where swipe south can't be
|
||||
-- used to close and where we then allow any multiswipe to close, allow any
|
||||
-- multiswipe to close this widget too.
|
||||
ReaderProgress.onMultiSwipe = ReaderProgress.onClose
|
||||
|
||||
|
||||
return ReaderProgress
|
||||
|
||||
Reference in New Issue
Block a user