Skip to content

Regreesion: bevy:: window ::close_on_esc doesn't work correctly #7612

@ameknite

Description

@ameknite

Bevy version

Main
Commit: 9ef840e

Relevant system information

  • SystemInfo { os: "MacOS 13.2 ", kernel: "22.3.0", cpu: "Apple M1" }

What you did

I was looking at the new examples and I came across this system:

bevy::window::close_on_esc

pub fn close_on_esc(
    mut commands: Commands,
    focused_windows: Query<(Entity, &Window)>,
    input: Res<Input<KeyCode>>,
) {
    for (window, focus) in focused_windows.iter() {
        if !focus.focused {
            continue;
        }

        if input.just_pressed(KeyCode::Escape) {
            commands.entity(window).despawn();
        }
    }
}

What went wrong

It doesn't close the window when I press Esc.
I have to click outside the window and back inside the window and it works.

Additional information

  • It works fine in 0.9.1
  • When I print focus.focused it says false, it doesn't seem to detect focus the first time I run the program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-WindowingPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions