add ime support

This commit is contained in:
endlesstravel 2016-11-06 15:06:58 +08:00
parent 3171286c1f
commit 4638fb1ea5
7 changed files with 162 additions and 40 deletions

View file

@ -52,10 +52,10 @@ return function(core, input, ...)
opt.state = core:registerHitbox(opt.id, x,y,w,h)
opt.hasKeyboardFocus = core:grabKeyboardFocus(opt.id)
if opt.hasKeyboardFocus then
if (input.candidate_text.text == "") and opt.hasKeyboardFocus then
local keycode,char = core:getPressedKey()
-- text input
if char ~= "" then
if char and char ~= "" then
local a,b = split(input.text, input.cursor)
input.text = table.concat{a, char, b}
input.cursor = input.cursor + utf8.len(char)