support submit2 for EditFields

develop
myk002 2022-07-15 13:46:01 -07:00
parent f3539f06c8
commit 9b340a7630
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 13 additions and 0 deletions

@ -3882,6 +3882,7 @@ Attributes:
If it returns false, the character is ignored. If it returns false, the character is ignored.
:on_change: Change notification callback; used as ``on_change(new_text,old_text)``. :on_change: Change notification callback; used as ``on_change(new_text,old_text)``.
:on_submit: Enter key callback; if set the field will handle the key and call ``on_submit(text)``. :on_submit: Enter key callback; if set the field will handle the key and call ``on_submit(text)``.
:on_submit2: Shift-Enter key callback; if set the field will handle the key and call ``on_submit2(text)``.
:key: If specified, the field is disabled until this key is pressed. Must be given as a string. :key: If specified, the field is disabled until this key is pressed. Must be given as a string.
:key_sep: If specified, will be used to customize how the activation key is :key_sep: If specified, will be used to customize how the activation key is
displayed. See ``token.key_sep`` in the ``Label`` documentation below. displayed. See ``token.key_sep`` in the ``Label`` documentation below.

@ -184,6 +184,7 @@ EditField.ATTRS{
on_char = DEFAULT_NIL, on_char = DEFAULT_NIL,
on_change = DEFAULT_NIL, on_change = DEFAULT_NIL,
on_submit = DEFAULT_NIL, on_submit = DEFAULT_NIL,
on_submit2 = DEFAULT_NIL,
key = DEFAULT_NIL, key = DEFAULT_NIL,
key_sep = DEFAULT_NIL, key_sep = DEFAULT_NIL,
frame = {h=1}, frame = {h=1},
@ -253,6 +254,17 @@ function EditField:onInput(keys)
return not not self.key return not not self.key
end end
if keys.SEC_SELECT then
if self.key then
self:setFocus(false)
end
if self.on_submit2 then
self.on_submit2(self.text)
return true
end
return not not self.key
end
if keys._STRING then if keys._STRING then
local old = self.text local old = self.text
if keys._STRING == 0 then if keys._STRING == 0 then