From 6ccb2a306e1b518638aa382b2673d1067998a32f Mon Sep 17 00:00:00 2001 From: Mateusz Wachowiak Date: Wed, 3 Apr 2024 20:02:50 +0200 Subject: [PATCH] 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>, ) { for (window, focus) in focused_windows.iter() { if !focus.focused { continue; } if input.just_pressed(KeyCode::Escape) { commands.entity(window).despawn(); } } } ``` --- crates/bevy_dev_tools/src/close_on_esc.rs | 32 ----------------------- crates/bevy_dev_tools/src/lib.rs | 4 --- 2 files changed, 36 deletions(-) delete mode 100644 crates/bevy_dev_tools/src/close_on_esc.rs diff --git a/crates/bevy_dev_tools/src/close_on_esc.rs b/crates/bevy_dev_tools/src/close_on_esc.rs deleted file mode 100644 index a3245caed8ffa..0000000000000 --- a/crates/bevy_dev_tools/src/close_on_esc.rs +++ /dev/null @@ -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 (Esc) 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>, -) { - for (window, focus) in focused_windows.iter() { - if !focus.focused { - continue; - } - - if input.just_pressed(KeyCode::Escape) { - commands.entity(window).despawn(); - } - } -} diff --git a/crates/bevy_dev_tools/src/lib.rs b/crates/bevy_dev_tools/src/lib.rs index 957e6ab83a909..b9f3fae5afa79 100644 --- a/crates/bevy_dev_tools/src/lib.rs +++ b/crates/bevy_dev_tools/src/lib.rs @@ -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. ///