mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Tweak `mergeTitleBarIntoLayout` to keep the current selection (adjusted for the added rows) instead of resetting the focus. It only actually called `moveFocusTo` on `hasDPad` devices, which explains why this was missed during testing. Fix https://github.com/koreader/koreader/pull/12583#issuecomment-2423554770
This commit is contained in:
@@ -1136,21 +1136,16 @@ function Menu:mergeTitleBarIntoLayout()
|
||||
-- Title bar items can be accessed through key mappings on kindle
|
||||
return
|
||||
end
|
||||
local menu_item_layout_start_row = 1
|
||||
-- On hasFewKeys devices, Menu uses the "Right" key to trigger the context menu: we can't use it to move focus in horizontal directions.
|
||||
-- So, add title bar buttons to FocusManager's layout in a vertical-only layout
|
||||
local title_bar_layout = self.title_bar:generateVerticalLayout()
|
||||
for _, row in ipairs(title_bar_layout) do
|
||||
table.insert(self.layout, menu_item_layout_start_row, row)
|
||||
menu_item_layout_start_row = menu_item_layout_start_row + 1
|
||||
end
|
||||
if menu_item_layout_start_row > #self.layout then -- no menu items
|
||||
menu_item_layout_start_row = #self.layout -- avoid index overflow
|
||||
end
|
||||
if Device:hasDPad() then
|
||||
-- Move focus to the first menu item, if any, in keeping with the pre-FocusManager behavior
|
||||
self:moveFocusTo(1, menu_item_layout_start_row, FocusManager.NOT_FOCUS)
|
||||
for i, row in ipairs(title_bar_layout) do
|
||||
-- Insert the title bar in the top rows of our layout
|
||||
table.insert(self.layout, i, row)
|
||||
end
|
||||
-- Adjust for the added rows to keep our current selection
|
||||
self.selected.y = self.selected.y + #title_bar_layout
|
||||
logger.dbg("Menu:mergeTitleBarIntoLayout: Adjusted focus position to account for added titlebar rows:", self.selected.x, ",", self.selected.y)
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
@@ -139,6 +139,7 @@ function CoverMenu:updateItems(select_number, no_recalculate_dimen)
|
||||
|
||||
-- As done in Menu:updateItems()
|
||||
self:updatePageInfo(select_number)
|
||||
Menu.mergeTitleBarIntoLayout(self)
|
||||
|
||||
self.show_parent.dithered = self._has_cover_images
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
@@ -316,7 +317,6 @@ function CoverMenu:updateItems(select_number, no_recalculate_dimen)
|
||||
self.showFileDialog_ours = self.showFileDialog
|
||||
end)
|
||||
end
|
||||
Menu.mergeTitleBarIntoLayout(self)
|
||||
end
|
||||
|
||||
-- Similar to showFileDialog setup just above, but for History,
|
||||
|
||||
Reference in New Issue
Block a user