Skip to content

Add double-click-and-drag and triple-click-and-drag text selection - #8370

Open
mudbungie wants to merge 1 commit into
emilk:mainfrom
mudbungie:word-drag-selection
Open

Add double-click-and-drag and triple-click-and-drag text selection#8370
mudbungie wants to merge 1 commit into
emilk:mainfrom
mudbungie:word-drag-selection

Conversation

@mudbungie

Copy link
Copy Markdown

Double-click-and-drag now extends the selection by whole words, and triple-click-and-drag by whole lines — in both TextEdit and labels, including selections spanning multiple labels.

double-click-and-drag selecting by words

The reason this was missing: clicks are only counted on pointer release, so at the start of a drag nothing knew it began with a double-click.

  • PointerState now also computes the would-be click count at press time (pub(crate) only, same heuristics as the click counting on release).
  • On a second/third press, TextCursorState selects the word/line under the pointer immediately and remembers it as the anchor; while dragging, the selection is the union of the anchor and the word/line under the pointer. A side effect is that plain double-click selection now appears on press rather than release, matching other UI toolkits.
  • LabelSelectionState carries the anchor across passes, so the drag can extend into neighboring labels.

No public API changes. Covered by unit tests for the range math and kittest tests for TextEdit (forward/backward/lines) and cross-label drags in tests/egui_tests/tests/test_text_selection.rs.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

Preview is being built...

Preview will be available at https://egui-pr-preview.github.io/pr/8370-word-drag-selection

View snapshot changes at kitdiff

@mudbungie
mudbungie marked this pull request as ready for review August 1, 2026 23:53
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.

Add double-click and drag and triple-click and drag to select multiple words and to select multiple paragraphs

1 participant