Skip to content

Commit

Permalink
allow keyboard navigation to exit text entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauumm committed Nov 4, 2023
1 parent d42a850 commit 642bc34
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ui/elements/entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,16 @@ function entry:process_event(name, ...)
elseif self.cursor_pos < 0 then
self.cursor_pos = 0
end
self.element:scroll_into_view(
self.label.padding * self.scale + self.cursor_pixel_pos - self.scale * 20,
0,
self.scale * 40,
0
)
self.cursor_pixel_pos = self.label.text:getFont():getWidth(text:sub(1, self.cursor_pos))
stop_propagation = true
if self.cursor_pos ~= last_cursor_pos then
self.element:scroll_into_view(
self.label.padding * self.scale + self.cursor_pixel_pos - self.scale * 20,
0,
self.scale * 40,
0
)
self.cursor_pixel_pos = self.label.text:getFont():getWidth(text:sub(1, self.cursor_pos))
stop_propagation = true
end
end
return stop_propagation
end
Expand Down

0 comments on commit 642bc34

Please sign in to comment.