Add double-click-and-drag and triple-click-and-drag text selection - #8370
Open
mudbungie wants to merge 1 commit into
Open
Add double-click-and-drag and triple-click-and-drag text selection#8370mudbungie wants to merge 1 commit into
mudbungie wants to merge 1 commit into
Conversation
|
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
marked this pull request as ready for review
August 1, 2026 23:53
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.
Double-click-and-drag now extends the selection by whole words, and triple-click-and-drag by whole lines — in both
TextEditand labels, including selections spanning multiple labels.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.
PointerStatenow also computes the would-be click count at press time (pub(crate)only, same heuristics as the click counting on release).TextCursorStateselects 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.LabelSelectionStatecarries 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 intests/egui_tests/tests/test_text_selection.rs.