Skip to content

Touch Improvements to TextBox#20848

Merged
MrJul merged 20 commits into
masterfrom
textbox_touch_improvement
Mar 31, 2026
Merged

Touch Improvements to TextBox#20848
MrJul merged 20 commits into
masterfrom
textbox_touch_improvement

Conversation

@emmauss

@emmauss emmauss commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

This PR adds a lot of improvements for touch controls for textbox. Pointer handling for Touch input has been reworked to feel more natural for touch based devices. New behavior closely matches Android's default touch behavior for text inputs.
The following changes and improvements have been made;

  1. Scroll gesture has priority if its possible to scroll, otherwise moving the pointer across the textbox will move the caret position.
  2. Holding on text will select the word and show selection handles.
  3. Selection handles are larger.
  4. Holding on a selected text region will show the textbox's context menu.
  5. Selection handle control theme has been improved. Default theme uses combined geometry instead of a geometry group. PathIcon replaced with Image
  6. An indicator element is now part of the selection handle control theme. Caret or selection position is now set based on the indicator position, and not the whole handle position.
  7. SelectionHandles properly hide when out of bounds in the textbox. Behavior is more accurate now with the use of the presenter's transformed Clip region.
  8. Text Selector Layer is now below the PopupOverlayLayer,allowing flyouts to show above the selection handles on embedded devices.
  9. Scroll gesture has been updated to send gesture event only when the touch pointer actually moves.
  10. Selection Handles properly detects and adapt to RTL text.

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

TextSelectionHandle control theme is updated.

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063110-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss force-pushed the textbox_touch_improvement branch from 344b20e to c07d2c3 Compare March 13, 2026 10:30
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063361-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063371-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss force-pushed the textbox_touch_improvement branch from bb3444b to 9823926 Compare March 15, 2026 22:17
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063515-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063538-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063549-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss force-pushed the textbox_touch_improvement branch from 1523fc7 to 45b9fe2 Compare March 18, 2026 12:33
@emmauss emmauss marked this pull request as ready for review March 18, 2026 12:37
@emmauss emmauss changed the title [WIP] Touch Improvements to TextBox Touch Improvements to TextBox Mar 18, 2026
@emmauss emmauss requested a review from MrJul March 18, 2026 12:41
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0063613-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Comment thread src/Avalonia.Base/Input/GestureRecognizers/VelocityTracker.cs Outdated
Comment thread src/Avalonia.Controls/Primitives/TextSelectionHandle.cs Outdated
Comment thread src/Avalonia.Controls/Primitives/TextSelectionCanvas.cs Outdated
Comment thread src/Avalonia.Controls/Primitives/TextSelectionCanvas.cs Outdated
Comment thread src/Avalonia.Controls/TextBox.cs Outdated
Comment thread src/Avalonia.Controls/Primitives/TextSelectionCanvas.cs Outdated
if(!e.Handled)
{
// Gesture may cause an overscroll so we mark the event as handled if it did.
e.Handled = canXScroll || canYScroll;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure I understand the logic here, won't that prevent scroll chaining in this case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmed while testing, scroll chaining does not work correctly anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@MrJul

MrJul commented Mar 19, 2026

Copy link
Copy Markdown
Member

There's a regression when a selection is active with the context menu open. Previously, double-tapping another word would select it in this case. Now, you need 3 taps instead (one to close the popup, then two for the normal double-tap selection to activate).

Please add a test for this once fixed.

@MrJul

MrJul commented Mar 19, 2026

Copy link
Copy Markdown
Member

I've tested this with a touch screen, and overall, the changes are quite good :)
However, there are some regressions here.

We need more unit tests overall for this. This is not the easiest area to test, but we should be able to validate most of the behaviors added by this PR. They are too easy to break with future changes otherwise.

@emmauss emmauss force-pushed the textbox_touch_improvement branch from 45b9fe2 to 2c81338 Compare March 25, 2026 16:05
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0064039-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss force-pushed the textbox_touch_improvement branch from c2b5d46 to 838793d Compare March 26, 2026 11:34
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0064077-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss force-pushed the textbox_touch_improvement branch from 838793d to b225d0c Compare March 26, 2026 12:11
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0064079-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss requested a review from MrJul March 26, 2026 12:57
@emmauss

emmauss commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

@MrJul Added tests

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0064135-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@MrJul MrJul added this pull request to the merge queue Mar 31, 2026
Merged via the queue into master with commit ac28a74 Mar 31, 2026
11 checks passed
@MrJul MrJul deleted the textbox_touch_improvement branch March 31, 2026 16:04
@lui62233 lui62233 mentioned this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants