mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fix crash with keyboard navigation of onHold buttontables (#3307)
* Fix crash with keyboard navigation of onHold buttontables Would crash when encountering a separator or when the number of buttons in a row changes. * Reset previous selected item on new buttontable
This commit is contained in:
@@ -27,6 +27,7 @@ local ButtonTable = FocusManager:new{
|
||||
}
|
||||
|
||||
function ButtonTable:init()
|
||||
self.selected = { x = 1, y = 1 }
|
||||
self.buttons_layout = {}
|
||||
self.container = VerticalGroup:new{ width = self.width }
|
||||
table.insert(self, self.container)
|
||||
|
||||
@@ -73,8 +73,15 @@ function FocusManager:onFocusMove(args)
|
||||
end
|
||||
else
|
||||
self.selected.y = self.selected.y + dy
|
||||
if #self.layout[self.selected.y] == 0 then -- horizontal separator
|
||||
self.selected.y = self.selected.y + dy -- skip it
|
||||
end
|
||||
end
|
||||
self.selected.x = self.selected.x + dx
|
||||
if self.selected.x > #self.layout[self.selected.y] then
|
||||
-- smaller nb of items on new row than on prev row
|
||||
self.selected.x = #self.layout[self.selected.y]
|
||||
end
|
||||
|
||||
if self.layout[self.selected.y][self.selected.x] ~= current_item
|
||||
or not self.layout[self.selected.y][self.selected.x].is_inactive then
|
||||
|
||||
Reference in New Issue
Block a user