Skip to content
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

Caret behavior by single tap in Cupertino textfields #858

Conversation

mazunin-v-jb
Copy link

Proposed Changes

  • Split behavior for focused and unfocused state, like in native applications.
  • Added behavior logic for focused state of text field.
  • Forwarded callback for showing context menu actions by tap on the caret.

Testing

Test: Run App, open Components - TextField - Almost Fullscreen. Try cases described in the documentation of cupertinoSetCursorOffsetFocused()

Issues Fixed

https://youtrack.jetbrains.com/issue/COMPOSE-445/iOS-adjust-caret-behavior-in-textfields-for-single-tap

Google CLA

You need to sign the Google Contributor’s License Agreement at https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP repository. Signing this agreement allows us to synchronise code from your Pull Requests as well.

…tyled textfield.

Forwarded callback for showing context menu (should be called by tap on the caret)
@mazunin-v-jb mazunin-v-jb self-assigned this Oct 2, 2023
currentState.processor,
currentOffsetMapping,
currentState.onValueChange
TextFieldDelegate.cupertinoSetCursorOffsetFocused(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an ability to move cursor to the middle of a word?

As in iOS native apps:

image

(or differently for now).

If we don't have that, we should postpone merging this PR, otherwise we'll block the ability to move the cursor to the middle

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now we don't have. I didn't want to merge it asap.
I have tasks for implementing this (1, 2), so I think this PR could easily be postponed.

Copy link
Author

@mazunin-v-jb mazunin-v-jb Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is
#913

@MatkovIvan maybe you want to look at it too

@mazunin-v-jb mazunin-v-jb marked this pull request as draft October 26, 2023 10:37
… handling to ui-text, changed logic of caret behavior, added tests
@mazunin-v-jb mazunin-v-jb marked this pull request as ready for review November 17, 2023 17:43
…n, removed changes in public API (ui-text), refactor logic in TextFieldDelegate.skiko.kt, added documentation to some supplementary functions
@mazunin-v-jb mazunin-v-jb requested a review from igordmn November 28, 2023 17:25
@mazunin-v-jb mazunin-v-jb merged commit 928fa13 into jb-main Dec 7, 2023
1 check passed
@mazunin-v-jb mazunin-v-jb deleted the v.mazunin/dev/single-tap-native-behavior-in-cupertino-textfield branch December 7, 2023 12:29
mazunin-v-jb added a commit that referenced this pull request Dec 7, 2023
## Proposed Changes

- Split behavior for focused and unfocused state, like in native
applications.
  - Added behavior logic for focused state of text field.
- Forwarded callback for showing context menu actions by tap on the
caret.

## Testing

Test: Run App, open Components - TextField - Almost Fullscreen. Try
cases described in the documentation of
`cupertinoSetCursorOffsetFocused() `

## Issues Fixed


https://youtrack.jetbrains.com/issue/COMPOSE-445/iOS-adjust-caret-behavior-in-textfields-for-single-tap


## Google CLA
You need to sign the Google Contributor’s License Agreement at
https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP
repository. Signing this agreement allows us to synchronise code from
your Pull Requests as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants