-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support singleLine and KeyboardAction on iOS #699
Conversation
f33901e
to
9d2905b
Compare
9d2905b
to
41556ad
Compare
- Added UIKitTextInputService.runImeActionIfRequired that calls the current keyboard action if needed - Added UIKitTextInputService.onKeyEvent that calls a keyboard action when required - Prevented UIKitTextInputService.skikoInput from adding a new line character when singleLine = true or a keyboard action needs to be called - Passed UIKitTextInputService::onKeyEvent to ComposeLayer.setContent from ComposeWindow
…single hardware key press
…gleLine is true on iOS
Hello! Big thanks, it looks very usefull But, first can you please sign the Google Contributor’s License Agreement at https://cla.developers.google.com/. As a referece, you can look at screenshots in this PR: #521 |
And can you please provide a screenshot of the signed agreement? |
Thanks for a screenshot! |
You got 1 approve! But please wait for my approve too. |
@devjorgecastro That image shows that I'm registered as a contributor to Google's open-source projects. Contributions here will eventually be merged into the original Google repository, so you have to sign in at https://cla.developers.google.com/ if you want to make a PR. |
Proposed Changes
For iOS
singleLine
andKeyboardAction
supportUIKitTextInputService.runImeActionRequired
that checks whether a keyboard action needs to be called and calls it if neededUIKitTextInputService.onPreviewKeyEvent
for hardware keyboard event debouncingUIKitTextInputService.skikoInput.insertText
callUIKitTextInputService.runImeActionRequired
when the given character is a new line characterUIKitTextInputService.skikoInput.insertText
from adding a new line character whensingleLine
istrue
or a keyboard action needs to be calledUIKitTextInputService::onPreviewKeyEvent
toComposeLayer.setContent
fromComposeWindow
On some Android devices, the behavior of text fields is different when with hardware keyboards and with software keyboards. As you can see in the video below, on Android, the behavior of
ImeAction.Search
withsingleLine = false
is different, where theSearch
action is called with software keyboards while not called with hardware keyboards. Also, on some virtual Android devices (for me, it was Resizable (Experimental) API 33), whensingleLine
istrue
and the current IME action isImeAction.Default
, theDone
action is called with software keyboards while not called with hardware keyboards.The current behavior of text fields in this PR is as follows. When an IME action is called, the new line character is always prevented from being added.
singleLine = true
singleLine = false
ImeAction.Default
Done
action.ImeAction.None
ImeAction.Search
Search
action.Search
action only when the software keyboard is used, does nothing otherwisesingleLine
.For iOS hardware keyboard bug fix
UIKitTextInputService.onPreviewKeyEvent
consumeKEY_ENTER
andKEY_BACKSPACE
down events to prevent double new line characters or double character removing when using hardware keyboardsTesting
Test: Tested using the Android & iOS template with the following configuration:
App.kt
is modified as the code below.Issues Fixed
Fixes: JetBrains/compose-multiplatform#2794
Test Code
Test Results (iOS
singleLine
andKeyboardAction
support)Galaxy.Tab.S8.Software.mp4
Galaxy.Tab.S8.Hardware.mp4
iPad.Pro.Software.mov
iPad.Pro.Hardware.MP4
Test Results (iOS hardware keyboard bug fix)
Tested with
hello <return> <return> world <backspace> <backspace>
.Before the fix:
iPad.Pro.Before.MP4
After the fix:
iPad.Pro.After.MP4