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

Support text paste on iOS #653

Merged
merged 4 commits into from
Nov 1, 2024
Merged

Support text paste on iOS #653

merged 4 commits into from
Nov 1, 2024

Conversation

kmagiera
Copy link
Member

@kmagiera kmagiera commented Oct 23, 2024

This PR adds text paste support on iOS.

For Android, we use simulator-server to pass paste command. On iOS that was tricky to do and since there's a simctl command for paste we can use that instead.

In this change, we are overriding the sendPaste implementation for iOS that uses simctl pbcopy command that expects the pasted text to be sent via standard input.

In addition, we disable sending cmd+v key combination as HID keys to the simulator. It turned out to result in a buggy behavior when sometimes the key combination would trigger paste action and actually paste text into a focused text input, while most of the times it'd just do nothing. There were also instances where the previous text was pasted instead. Blocking this behavior isn't ideal but it puts iOS functionality in pair with Android while also avoiding a number of issues. It appears like the bugs are not caused by the IDE since we also observe these when testing paste functionality with the standard iOS simulator app.

Closes: #553

How Has This Been Tested:

  1. Open any text example, add TextInput field
  2. Copy some text using cmd+c and use cmd+v with the iOS simulator focused
  3. Now when long-pressing the input field you can paste the copied text

Copy link

vercel bot commented Oct 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 10:39pm

@filip131311
Copy link
Collaborator

This change does not work as described, it does add copied text to clipboard after pressing cmd+v but it unpredictably either pastes the text to the TextInput, or sends a dialogue box to the user, the dialogue box sometiemes only flashes and sometimes stays on.

Screen.Recording.2024-10-23.at.16.33.03.mov
Screenshot 2024-10-23 at 16 31 27

Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

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

left explanation inline

// pressing V first and then cmd, but it is good enough to filter out
// the majority of the noisy behavior since typically you press cmd first.
if (keyCode === LEFT_META_HID_CODE || keyCode === RIGHT_META_HID_CODE) {
this.pressingMetaKeys += direction === "Down" ? 1 : -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a good approach as it assumes that meatKey "up" event is going to happen, but if it won't it will brak the v key forever.

How to reproduce a problem:

  1. Click cmd with Simulator focused
  2. still holding cmd key click on something outside the ide and the release the cmd key
  3. the v key is now unusable

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't the described scenario break all the keys though? In this case the simulator would think that the meta key is pressed the whole time so other keys shouldn't be interactive as well. I don't think fixing this is within the scope of this PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

you are correct that this is a larger problem, but in the more general example the keyboard recovers after pressing and releasing cmd key, but this solution introduces a new bug that in this scenario disables exclusively the v key

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the code to use bool flags instead of the counter, so now you'll be able to recover from this issue by pressing meta key again

…ple release meta keys after focusing away from the IDE panel
@kmagiera kmagiera merged commit 2245b70 into main Nov 1, 2024
4 checks passed
@kmagiera kmagiera deleted the kmagiera/paste-on-ios branch November 1, 2024 17:59
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.

Copy/paste support for iOS
2 participants