[input] Reset cursor position on focus change.

This commit is contained in:
Lorenzo Cogotti 2022-10-02 18:52:39 +02:00
parent e38e6fcfb5
commit c449b8c53f
1 changed files with 10 additions and 3 deletions

View File

@ -126,16 +126,23 @@ end
function Input:keyreleased(key)
if self.candidate.length == 0 then
local moveTo
if key == 'home' then
self.cursor = 1
elseif key == 'end' then
self.cursor = utf8.len(self.text)+1
elseif key == 'up' or key == 'down' then
self.ui:navigate(key)
moveTo = key
elseif key == 'tab' or key == 'return' then
self.ui:navigate('right')
moveTo = 'right'
elseif key == 'escape' then
self.ui:navigate('cancel')
moveTo = 'cancel'
end
if moveTo then
self.cursor = 1 -- reset cursor position
self.ui:navigate(moveTo)
end
end
end