Merge remote-tracking branch 'upstream/develop' into docs

develop
myk002 2022-08-25 21:59:01 -07:00
commit 0d3aa0fb28
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 20 additions and 20 deletions

@ -304,6 +304,26 @@ function EditField:onInput(keys)
self:setCursor(self.start_pos + mouse_x) self:setCursor(self.start_pos + mouse_x)
return true return true
end end
elseif keys._STRING then
local old = self.text
if keys._STRING == 0 then
-- handle backspace
local del_pos = self.cursor - 1
if del_pos > 0 then
self:setText(old:sub(1, del_pos-1) .. old:sub(del_pos+1),
del_pos)
end
else
local cv = string.char(keys._STRING)
if not self.on_char or self.on_char(cv, old) then
self:setText(old:sub(1,self.cursor-1)..cv..old:sub(self.cursor),
self.cursor + 1)
end
end
if self.on_change and self.text ~= old then
self.on_change(self.text, old)
end
return true
elseif keys.CURSOR_LEFT then elseif keys.CURSOR_LEFT then
self:setCursor(self.cursor - 1) self:setCursor(self.cursor - 1)
return true return true
@ -325,26 +345,6 @@ function EditField:onInput(keys)
elseif keys.A_CARE_MOVE_E then -- Alt-Right (end) elseif keys.A_CARE_MOVE_E then -- Alt-Right (end)
self:setCursor() self:setCursor()
return true return true
elseif keys._STRING then
local old = self.text
if keys._STRING == 0 then
-- handle backspace
local del_pos = self.cursor - 1
if del_pos > 0 then
self:setText(old:sub(1, del_pos-1) .. old:sub(del_pos+1),
del_pos)
end
else
local cv = string.char(keys._STRING)
if not self.on_char or self.on_char(cv, old) then
self:setText(old:sub(1,self.cursor-1)..cv..old:sub(self.cursor),
self.cursor + 1)
end
end
if self.on_change and self.text ~= old then
self.on_change(self.text, old)
end
return true
end end
-- if we're modal, then unconditionally eat all the input -- if we're modal, then unconditionally eat all the input