diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index 2ee7ea1d4..c06c2e3b4 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -1016,6 +1016,7 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location) -- (which might not be seen when covered by FootnoteWidget) local close_callback = nil if link.from_xpointer then -- coherent xpointer + self.ui.document:highlightXPointer() -- clear any previous one self.ui.document:highlightXPointer(link.from_xpointer) UIManager:setDirty(self.dialog, "ui") close_callback = function(footnote_height) @@ -1055,10 +1056,14 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location) UIManager:close(popup) self:onGotoLink(link, neglect_current_location) end, - on_tap_close_callback = function(arg, ges) - -- on tap outside, see if we are tapping on another footnote, + on_tap_close_callback = function(arg, ges, footnote_height) + -- On tap outside, see if we are tapping on another footnote, -- and display it if we do (avoid the need for 2 taps) - self:onTap(arg, ges) + if not self:onTap(arg, ges) then + -- If we did tap on another link, onTap has already cleared our + -- highlight. If not, call close_callback to unhighlight it. + close_callback(footnote_height) + end end, dialog = self.dialog, } diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua index 7b386f543..b07843534 100644 --- a/frontend/ui/widget/footnotewidget.lua +++ b/frontend/ui/widget/footnotewidget.lua @@ -289,9 +289,6 @@ function FootnoteWidget:onShow() end function FootnoteWidget:onCloseWidget() - if self.close_callback then - self.close_callback(self.height) - end UIManager:setDirty(self.dialog, function() return "partial", self.container.dimen end) @@ -310,7 +307,9 @@ function FootnoteWidget:onTapClose(arg, ges) -- it. This avoids having to tap 2 times to -- see another footnote. if self.on_tap_close_callback then - self.on_tap_close_callback(arg, ges) + self.on_tap_close_callback(arg, ges, self.height) + elseif self.close_callback then + self.close_callback(self.height) end return true end @@ -320,6 +319,9 @@ end function FootnoteWidget:onSwipeFollow(arg, ges) if ges.direction == "west" then if self.follow_callback then + if self.close_callback then + self.close_callback(self.height) + end return self.follow_callback() end elseif ges.direction == "south" or ges.direction == "east" then @@ -328,6 +330,9 @@ function FootnoteWidget:onSwipeFollow(arg, ges) -- work only when started outside the footnote. -- Also allow closing with swipe east (like we do to go back -- from link) + if self.close_callback then + self.close_callback(self.height) + end self:onClose() return true elseif ges.direction == "north" then