-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Opening a Window on keyboard_input.just_pressed makes it trigger again #12273
Copy link
Copy link
Closed
Labels
A-InputPlayer input via keyboard, mouse, gamepad, and morePlayer input via keyboard, mouse, gamepad, and moreA-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrongThis issue requires detective work to figure out what's going wrong
Description
Bevy version
0.13
[Optional] Relevant system information
Windows 11
What you did
I made a system similar to the one in the keyboard_input example. But on the check whether the key A was just pressed, I then spawn a window.
fn spawn_debug_window(input: Res<ButtonInput<KeyCode>>, mut commands: Commands) {
if input.just_pressed(KeyCode::F1) {
info!("just pressed");
commands.spawn(Window {
title: "Debug".to_owned(),
..Default::default()
});
}
}What went wrong
It spams opening new windows, the just_pressed is held for multiple frames.
I think this happens because it opens a new window, thus the focus is on the new window and the press counts as a new press?
2024-03-03T11:54:46.916247Z INFO my_project::debug: just pressed
2024-03-03T11:54:46.930608Z INFO bevy_winit::system: Creating new window "Debug" (25v4)
2024-03-03T11:54:46.967434Z INFO my_project::debug: just pressed
2024-03-03T11:54:46.974474Z INFO bevy_winit::system: Creating new window "Debug" (27v1)
2024-03-03T11:54:47.014095Z INFO my_project::debug: just pressed
2024-03-03T11:54:47.036982Z INFO bevy_winit::system: Creating new window "Debug" (29v1)
2024-03-03T11:54:47.078519Z INFO my_project::debug: just pressed
2024-03-03T11:54:47.119463Z INFO bevy_winit::system: Creating new window "Debug" (31v1)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-InputPlayer input via keyboard, mouse, gamepad, and morePlayer input via keyboard, mouse, gamepad, and moreA-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrongThis issue requires detective work to figure out what's going wrong