Skip to content

Commit

Permalink
fix last selected elem after screen change
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauumm committed Aug 20, 2023
1 parent 3c680ae commit 9b27603
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ui/keyboard_navigation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ local keyboard_navigation = {}
local current_screen
local selected_element

function keyboard_navigation.set_screen(screen)
current_screen = screen
selected_element = nil
end

function keyboard_navigation.get_screen()
return current_screen
end
Expand All @@ -32,6 +27,17 @@ local function get_first_element(element)
end
end

function keyboard_navigation.set_screen(screen)
if current_screen then
current_screen.last_selected_element = selected_element
end
current_screen = screen
keyboard_navigation.select_element()
if current_screen.last_selected_element then
keyboard_navigation.select_element(current_screen.last_selected_element)
end
end

local function scroll_into_view(element)
if element.parent then
scroll_into_view(element.parent)
Expand Down

0 comments on commit 9b27603

Please sign in to comment.