From 1b94aa8171c9ff2b2280b6f57566ef9b59aef282 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Fri, 1 Jan 2016 22:05:11 +0100 Subject: [PATCH] Fix utf-8 input --- theme.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theme.lua b/theme.lua index 8279e8a..3cd2bc4 100644 --- a/theme.lua +++ b/theme.lua @@ -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