Ensure char is valid

Fixes an error which could occur if an input's state was set to active without user interaction
This commit is contained in:
tex 2016-07-03 20:29:09 +08:00 committed by GitHub
parent 3fd6a6aecd
commit 1b374b41cf

View file

@ -55,7 +55,7 @@ return function(core, input, ...)
if 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 + 1