Define app once

This commit is contained in:
Ksaper 2023-02-24 22:18:13 +02:00
parent 87656129f7
commit 44af848a9c
1 changed files with 12 additions and 15 deletions

View File

@ -291,18 +291,16 @@ local function page_forward(self, dir)
end end
if self._private.current_page > 1 or self.wrap_page_scrolling then if self._private.current_page > 1 or self.wrap_page_scrolling then
local app = nil
if dir == "down" then if dir == "down" then
local app = self._private.grid:get_widgets_at(1, 1)[1] app = self._private.grid:get_widgets_at(1, 1)[1]
app:select() elseif dir == "right" then
else app = self._private.grid:get_widgets_at(pos.row, 1)[1]
local app = self._private.grid:get_widgets_at(pos.row, 1)[1]
if app == nil then if app == nil then
local app = self._private.grid.children[#self._private.grid.children] app = self._private.grid.children[#self._private.grid.children]
app:select()
else
app:select()
end end
end end
app:select()
end end
end end
@ -334,20 +332,19 @@ local function page_backward(self, dir)
end end
end end
local rows, columns = self._private.grid:get_dimension() local app = nil
if self._private.current_page < self._private.pages_count then if self._private.current_page < self._private.pages_count then
if dir == "up" then if dir == "up" then
local app = self._private.grid.children[#self._private.grid.children] app = self._private.grid.children[#self._private.grid.children]
app:select()
else else
-- Keep the same row from last page -- Keep the same row from last page
local app = self._private.grid:get_widgets_at(pos.row, columns)[1] local _, columns = self._private.grid:get_dimension()
app:select() app = self._private.grid:get_widgets_at(pos.row, columns)[1]
end end
elseif self.wrap_page_scrolling then elseif self.wrap_page_scrolling then
local app = self._private.grid.children[#self._private.grid.children] app = self._private.grid.children[#self._private.grid.children]
app:select()
end end
app:select()
end end
local function scroll(self, dir) local function scroll(self, dir)