mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
remove close_on_esc (#12859)
# Objective - Remove `close_on_esc` - For context about why we are removing it see: [discord](https://discordapp.com/channels/691052431525675048/692572690833473578/1225075194524073985) ## Migration Guide - Users who added `close_on_esc` in their application will have to replace it with their own solution. ```rust pub fn close_on_esc( mut commands: Commands, focused_windows: Query<(Entity, &Window)>, input: Res<ButtonInput<KeyCode>>, ) { for (window, focus) in focused_windows.iter() { if !focus.focused { continue; } if input.just_pressed(KeyCode::Escape) { commands.entity(window).despawn(); } } } ```
This commit is contained in:
parent
f516de456b
commit
6ccb2a306e
2 changed files with 0 additions and 36 deletions
|
@ -1,32 +0,0 @@
|
|||
use bevy_ecs::prelude::*;
|
||||
use bevy_input::{keyboard::KeyCode, ButtonInput};
|
||||
use bevy_window::Window;
|
||||
|
||||
/// Close the focused window whenever the escape key (<kbd>Esc</kbd>) is pressed
|
||||
///
|
||||
/// This is useful for examples or prototyping.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use bevy_app::prelude::*;
|
||||
/// # use bevy_dev_tools::close_on_esc;
|
||||
/// #
|
||||
/// App::new()
|
||||
/// .add_systems(Update, close_on_esc);
|
||||
/// ```
|
||||
pub fn close_on_esc(
|
||||
mut commands: Commands,
|
||||
focused_windows: Query<(Entity, &Window)>,
|
||||
input: Res<ButtonInput<KeyCode>>,
|
||||
) {
|
||||
for (window, focus) in focused_windows.iter() {
|
||||
if !focus.focused {
|
||||
continue;
|
||||
}
|
||||
|
||||
if input.just_pressed(KeyCode::Escape) {
|
||||
commands.entity(window).despawn();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,10 +18,6 @@ pub mod fps_overlay;
|
|||
#[cfg(feature = "bevy_ui_debug")]
|
||||
pub mod ui_debug_overlay;
|
||||
|
||||
mod close_on_esc;
|
||||
|
||||
pub use crate::close_on_esc::close_on_esc;
|
||||
|
||||
/// Enables developer tools in an [`App`]. This plugin is added automatically with `bevy_dev_tools`
|
||||
/// feature.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue