Files
ickshonpe 68c4223091 multi-click support (#24023)
# Objective

Implement minimal multi-click support.
Add double click to select word and triple click to select all support
to text input widgets.

Fixes #23874

## Solution

New `MULTI_CLICK_DURATION` constant that sets the max time between
clicks for them to count as consecutive.

Added a field `count` to `Click`. 1 is a single click, 2 is a double
click, 3 is a triple click and so on. It's a `u8` and saturates at 255
if you click that many times.

Current multi-click state is stored in a field `clicking` on
`PointerButtonState`.
The `clicking` state is cleared after `MULTI_CLICK_DURATION` without
another click.

New `SelectWordAtPoint` `TextEdit`.

New observer system `on_pointer_click` in `bevy_ui_widgets::text_input`.
This queues `SelectWordAtPoint` for 2 clicks and `SelectAll` for 3 or
more. `Click` events are dispatched on release, so they happen after
`Press`. The `Press` for a double click might move the cursor but that
doesn't affect the `SelectWordAtPoint` edit that is dispatched.

#

The implementation is deliberately minimal, I just added here what was
needed for the text input. Left for followups:
- Tracking the initial click position and returning the displacement
with `Click`.
- Spatial tolerance (clicks are only multi-clicks if the pointer hasn't
moved too far).
- Configurable multi-click duration.

We could add a separate `MultiClick` event instead. It seems to me
things would be more complicated with both `Click` and `MultiClick`
observer systems though.

## Testing

Text inputs now support double click to select a word and triple click
to select all:

```
cargo run --example multiline_text_input
```

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Talin <viridia@gmail.com>
2026-04-29 15:59:37 +00:00
..