mirror of
https://codeberg.org/1414codeforge/yui.git
synced 2025-02-17 20:30:55 +01:00
[input] Reset cursor position on focus change.
This commit is contained in:
parent
e38e6fcfb5
commit
c449b8c53f
13
input.lua
13
input.lua
@ -126,16 +126,23 @@ end
|
|||||||
|
|
||||||
function Input:keyreleased(key)
|
function Input:keyreleased(key)
|
||||||
if self.candidate.length == 0 then
|
if self.candidate.length == 0 then
|
||||||
|
local moveTo
|
||||||
|
|
||||||
if key == 'home' then
|
if key == 'home' then
|
||||||
self.cursor = 1
|
self.cursor = 1
|
||||||
elseif key == 'end' then
|
elseif key == 'end' then
|
||||||
self.cursor = utf8.len(self.text)+1
|
self.cursor = utf8.len(self.text)+1
|
||||||
elseif key == 'up' or key == 'down' then
|
elseif key == 'up' or key == 'down' then
|
||||||
self.ui:navigate(key)
|
moveTo = key
|
||||||
elseif key == 'tab' or key == 'return' then
|
elseif key == 'tab' or key == 'return' then
|
||||||
self.ui:navigate('right')
|
moveTo = 'right'
|
||||||
elseif key == 'escape' then
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user