Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ameknite opened this issue Feb 10, 2023 · 3 comments
Closed

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

ameknite opened this issue Feb 10, 2023 · 3 comments
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior
Milestone

Comments

@ameknite
Copy link
Contributor

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.
@ameknite ameknite added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Feb 10, 2023
@ameknite ameknite changed the title Regreesion: bevy::window::close_on_esc doesn't work correctly Regreesion: bevy:: window ::close_on_esc doesn't work correctly Feb 10, 2023
@mockersf
Copy link
Member

I'm on macOS too, and I get two focus event for the window on startup, one true then one false.

Could someone try to reproduce on another platform?

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in and removed S-Needs-Triage This issue needs to be labelled labels Feb 11, 2023
@alice-i-cecile alice-i-cecile added this to the 0.10 milestone Feb 11, 2023
@hymm
Copy link
Contributor

hymm commented Feb 13, 2023

was this fixed by #7628?

@mockersf
Copy link
Member

no, windows still start as unfocused

@bors bors bot closed this as completed in fae61ad Feb 14, 2023
myreprise1 pushed a commit to myreprise1/bevy that referenced this issue Feb 15, 2023
# Objective

- Fixes bevyengine#7612 
- Since bevyengine#7493, windows started as unfocused

## Solution

- Creating the window at the end of the event loop after the resume event instead of at the beginning of the loop of the next event fixes the focus
myreprise1 pushed a commit to myreprise1/bevy that referenced this issue Feb 15, 2023
# Objective

- Fixes bevyengine#7612 
- Since bevyengine#7493, windows started as unfocused

## Solution

- Creating the window at the end of the event loop after the resume event instead of at the beginning of the loop of the next event fixes the focus
myreprise1 pushed a commit to myreprise1/bevy that referenced this issue Feb 15, 2023
# Objective

- Fixes bevyengine#7612 
- Since bevyengine#7493, windows started as unfocused

## Solution

- Creating the window at the end of the event loop after the resume event instead of at the beginning of the loop of the next event fixes the focus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants