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

Fix: Menu not closing when clicking menu button #4552

Closed
wants to merge 1 commit into from

Conversation

fluxxcode
Copy link

@fluxxcode fluxxcode commented May 27, 2024

Fixed an issue where the menu would not close if the menu button was clicked while the menu was already open.

Behaviour before:

before.mp4

Behaviour after:

after.mp4

The problem was that the logic to close the menu when the user presses outside the menu, closed the menu before the menu button registered the click. This means the following code gets no longer called when clicking on the menu button and instead the menu will be opened again.

// menu.rs : 326

        if (button.clicked() && root.is_menu_open(id))
            || button.ctx.input(|i| i.key_pressed(Key::Escape))
        {
            // menu open and button clicked or esc pressed
            return MenuResponse::Close;
        }

I fixed the problem by checking whether the mouse is currently hovering over the menu button before closing the menu.

@fluxxcode fluxxcode changed the title Fix menu not closing when clicking menu button Fix: Menu not closing when clicking menu button May 27, 2024
@fluxxcode
Copy link
Author

Closing as this is already fixed in the latest egui version

@fluxxcode fluxxcode closed this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant