bevy/examples/window
Johan Klokkhammer Helsing 7ebc68bb84 Allow not preventing default event behaviors on wasm (#7304)
# Objective

On wasm, bevy applications currently prevent any of the normal browser hotkeys from working normally (Ctrl+R, F12, F5, Ctrl+F5, tab, etc.).

Some of those events you may want to override, perhaps you can hold the tab key for showing in-game stats?

However, if you want to make a well-behaved game, you probably don't want to needlessly prevent that behavior unless you have a good reason.

Secondary motivation: Also, consider the workaround presented here to get audio working: https://developer.chrome.com/blog/web-audio-autoplay/#moving-forward ; It won't work (for keydown events) if we stop event propagation.

## Solution

- Winit has a field that allows it to not stop event propagation, expose it on the window settings to allow the user to choose the desired behavior. Default to `true` for backwards compatibility.

---

## Changelog

- Added `Window::prevent_default_event_handling` . This allows bevy apps to not override default browser behavior on hotkeys like F5, F12, Ctrl+R etc.
2023-01-22 23:35:32 +00:00
..
clear_color.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
low_power.rs Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
multiple_windows.rs Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
scale_factor_override.rs Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
transparent_window.rs Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
window_resizing.rs Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
window_settings.rs Allow not preventing default event behaviors on wasm (#7304) 2023-01-22 23:35:32 +00:00