The `ui_focus_system` from `bevy_ui` doesn't handle touch input correctly
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
Tested on both 0.5.0 and the current master 71bf07f5c085b9c02cbe5337040337c3ed8b0002
## Operating system & version
Windows 10 with touch screen
## What you did
Run the button example (`cargo run --example button`) and try to interact with the button by touch.
## What you expected to happen
The button should say `Press` just as with clicking with a mouse.
## What actually happened
Nothing (no change to the button at all).
## Additional information
It seems that there are multiple bugs in trying to handle the touch input in `ui_focus_system` (from `bevy_ui`).
The `current_position` is taken from the cursor position, not the touch (this means that the system doesn't even recognize the touch if the cursor is not in the primary window.
The option `just_cancelled` is not handled at all. (So the `Interaction` stays at `Clicked`.)
I noticed that there is a line (notice the `just_released` at the touch input)
`let mouse_clicked = mouse_button_input.just_pressed(MouseButton::Left) || touches_input.just_released(0);`
The code uses the `id: 0`, but when I tested it, every touch gives a new `id` - and it persists through multiple runs of the example. So I believe that my OS gives a new `id` for every touch since reboot.
At first I wanted to make the changes myself to relieve you from some work, but it seems that it will need some more complex changes (like handling multiple touch inputs at the same time - second touch shouldn't cancel the first one, ...).
### Some additional thoughts:
Touch inputs shouldn't be handled in the same way as mouse input, because:
- In touch screens, long clicks are interpreted as hover in most places
- You can have multiple touches at the same time - which shouldn't be interpreted as multiple clicks (because of e.g. resizing gestures)
## Proposed solution
Remove the touch input handling from `Interaction` until there is a better solution. I don't know if the touch input handling for buttons works somewhere, in which case I would leave it for know.
Contributor guide
Assessment
This issue has not been assessed yet.