[InputText] Toggle on-screen keyboard with a lone Sym/ScreenKB tap (#15669)
On devices with a physical keyboard (e.g. Kindle), the on-screen keyboard can already be toggled while a text field is focused via Shift/ScreenKB + Home. This adds a lone tap of the physical Sym key as an additional, more natural trigger. Sym is otherwise a held modifier for the symbol layer, and Input:handleKeyBoardEv swallows a bare modifier press/release before it becomes a key event. Detect a Sym press+release with no other key in between and surface it as a dedicated "SymPress" key event, which InputText handles the same way as the existing Shift/ScreenKB + Home toggle. The symbol layer (Sym+<key>) is unaffected: any intervening key press clears the lone-tap state, so only a true solo tap fires. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c6f6e75021
commit
8a48cc4ff5
3 files changed
+65
-13
No files matched your search
@@ -796,6 +796,13 @@ function InputText:onKeyPress(key)
|
||||
if not self.focused then
|
||||
return false
|
||||
end
|
||||
|
||||
-- A lone Sym or ScreenKB key press toggles the on-screen keyboard, same as Shift/ScreenKB + Home.
|
||||
if key["SymPress"] or key["ScreenKBPress"] then
|
||||
self:toggleKeyboard()
|
||||
return self.keyboard ~= nil -- readonly fields have no keyboard: let the event bubble
|
||||
end
|
||||
|
||||
local handled = true
|
||||
|
||||
if not key["Ctrl"] and not key["Shift"] and not key["Alt"] and not key["ScreenKB"] then
|
||||
@@ -880,11 +887,7 @@ function InputText:onKeyPress(key)
|
||||
elseif key["Press"] then
|
||||
self:holdTextBox()
|
||||
elseif key["Home"] then
|
||||
if self.keyboard:isVisible() then
|
||||
self:onCloseKeyboard()
|
||||
else
|
||||
self:onShowKeyboard()
|
||||
end
|
||||
self:toggleKeyboard()
|
||||
elseif key["."] and Device:hasSymKey() then
|
||||
-- Kindle does not have a dedicated button for commas
|
||||
self:addChars(",")
|
||||
@@ -977,6 +980,15 @@ function InputText:isKeyboardVisible()
|
||||
return false
|
||||
end
|
||||
|
||||
-- Temporarily show/hide the on-screen keyboard, e.g. via Shift/ScreenKB + Home or a lone Sym/ScreenKB press.
|
||||
function InputText:toggleKeyboard()
|
||||
if self:isKeyboardVisible() then
|
||||
self:onCloseKeyboard()
|
||||
else
|
||||
self:onShowKeyboard()
|
||||
end
|
||||
end
|
||||
|
||||
function InputText:lockKeyboard(toggle)
|
||||
if self.keyboard then
|
||||
return self.keyboard:lockVisibility(toggle)
|
||||
|
||||
Reference in new issue
Block a user