[fix] InputText: fix ignoring first char when carat not in front of hint (#5052)

This commit is contained in:
limerainne
2019-06-01 23:48:35 +09:00
committed by Frans de Jonge
parent 1657c5e412
commit 98b681bb4f

View File

@@ -434,7 +434,11 @@ function InputText:addChars(chars)
if self.readonly or not self:isTextEditable(true) then
return
end
self.is_text_edited = true
if #self.charlist == 0 then -- widget text is empty or a hint text is displayed
self.charpos = 1 -- move cursor to the first position
end
table.insert(self.charlist, self.charpos, chars)
self.charpos = self.charpos + #util.splitToChars(chars)
self:initTextBox(table.concat(self.charlist), true)