also look in just_pressed touches for position (#7743)
# Objective - On some devices, UI buttons are not responsive ## Solution - On device with a slower frame rate, touch event can start and end in the frame rate - When looking for a touch position, also look into the `just_pressed` touches that are not cleared by the end event but only at the end of the frame Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
eb7f554ef7
commit
4134351d9b
@ -335,7 +335,13 @@ impl Touches {
|
||||
|
||||
/// Retrieves the position of the first currently pressed touch, if any
|
||||
pub fn first_pressed_position(&self) -> Option<Vec2> {
|
||||
self.pressed.values().next().map(|t| t.position)
|
||||
// Looking for the position in `pressed`. If nothing is found, also look into `just_pressed`
|
||||
// A touch can be in `just_pressed` but not in `pressed` if it ended in the same frame it started
|
||||
self.pressed
|
||||
.values()
|
||||
.next()
|
||||
.or_else(|| self.just_pressed.values().next())
|
||||
.map(|t| t.position)
|
||||
}
|
||||
|
||||
/// Clears `just_pressed`, `just_released`, and `just_canceled` data for every touch input.
|
||||
|
Loading…
Reference in New Issue
Block a user