Open
Description
Bevy version
tried with vanilla 0.13.1
Relevant system information
cargo/rust: 1.77
Safari: 17.4.1
What you did
altered one the bevy mouse button events examples:
use bevy::{input::mouse::MouseButtonInput, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, print_mouse_events_system)
.run();
}
fn print_mouse_events_system(
mut mouse_motion_events: EventReader<MouseButtonInput>,
window: Query<&Window>,
) {
for event in mouse_motion_events.read() {
if let Ok(w) = window.get(event.window) {
info!(
"mouse button: {:?} cursor_position: {:?}",
event.state,
w.cursor_position()
);
}
}
}
What went wrong
on Safari it does not allow getting the cursor_position from the window in the frame the mousebutton is released, seen in the log:
[Log] INFO src/main.rs:16 mouse button: Pressed cursor_position: Some(Vec2(441.0, 485.0)) (wasm_window_bug-8c728a0687bf9c77.js, line 489)
[Log] INFO src/main.rs:16 mouse button: Released cursor_position: None (wasm_window_bug-8c728a0687bf9c77.js, line 489)
on chrome and firefox when clicking (button down/up) inside the canvas it prints (as expected):
INFO src/main.rs:16 mouse button: Pressed cursor_position: Some(Vec2(566.0, 305.0)) wasm_window_bug-8c728a0687bf9c77.js:489:21
INFO src/main.rs:16 mouse button: Released cursor_position: Some(Vec2(566.0, 305.0)) wasm_window_bug-8c728a0687bf9c77.js:489:21
Additional information
I assume its a bug in bevy_winit
or winit
itself, but i did not drill deeper yet