Fix utf-8 input
This commit is contained in:
parent
b37f1ebd0a
commit
1b94aa8171
1 changed files with 2 additions and 2 deletions
|
@ -108,7 +108,7 @@ function theme.Input(input, opt, x,y,w,h)
|
|||
local tw = opt.font:getWidth(input.text)
|
||||
local cursor_pos = 0
|
||||
if input.cursor > 1 then
|
||||
local s = input.text:sub(0, utf8.offset(input.text, input.cursor-1))
|
||||
local s = input.text:sub(0, utf8.offset(input.text, input.cursor)-1)
|
||||
cursor_pos = opt.font:getWidth(s)
|
||||
end
|
||||
|
||||
|
@ -138,7 +138,7 @@ function theme.Input(input, opt, x,y,w,h)
|
|||
love.graphics.print(input.text, x, y+(h-th)/2)
|
||||
|
||||
-- cursor
|
||||
if opt.hasFocus then
|
||||
if opt.hasKeyboardFocus then
|
||||
love.graphics.line(x + cursor_pos, y + (h-th)/2,
|
||||
x + cursor_pos, y + (h+th)/2)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue