Files
egui/tests
Mud BungieandEmil Ernerfeldt 9c7bf826eb Add double-click-and-drag and triple-click-and-drag text selection (#8370)
* Closes <https://github.com/emilk/egui/issues/2550>
* [x] I have followed the instructions in the PR template

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](https://raw.githubusercontent.com/mudbungie/egui/media/double_click_drag.gif)

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`.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 08:01:15 +00:00
..

Test apps

Some application to tests various parts of egui and eframe.

At some point it would be nice to have automatic screenshot regression tests for these.