Support stylus/pen text selection on Android#7841
Open
DaniilBabanin wants to merge 1 commit into
Open
Conversation
The editor only used the pen-aware PointerEventHandler on iOS, or on Android when platform.isMobile was true. That flag comes from a "Mobi" token in the user agent, which Android tablets usually leave out, so on a tablet the editor fell back to TouchHandler and a stylus could only scroll, not select. Widen the check to any Android device when Pointer Events are available, the same as iOS already does. The iOS branch is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
A stylus or pen drag now selects text in the editor on Android, the same as it
already does on iOS. A finger drag still scrolls, and the mouse is unchanged.
Why
The editor only sends pointer input through PointerEventHandler, the handler
that lets a pen select while touch scrolls, on iOS or on Android when
platform.isMobile is true. platform.isMobile looks for a "Mobi" token in the
user agent, and Android tablets usually leave that token out. So on a tablet the
editor fell back to TouchHandler, and a stylus could only scroll, never select.
Android phones were unaffected because their user agent carries "Mobi".
Background: microsoft/vscode#198578 added the pen/stylus selection path for
mobile; this extends it to Android tablets.
The change
One line, in a new patch (patches/pen-support.diff):
The iOS branch is left as is. The only difference is that Android no longer
requires the isMobile flag to reach PointerEventHandler.
Testing
Built and run on a Samsung tablet with an S Pen, in Chrome:
Also reproducible in desktop Chrome with DevTools device mode set to an Android
tablet user agent that has no "Mobi" token.
Notes
iPad and iPhone are unaffected; the iOS branch is untouched. Android phones are
unaffected too, since they already satisfied isMobile.