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

Disabled widgets prevent focus from going to next widget #5359

Closed
lucasmerlin opened this issue Nov 8, 2024 · 0 comments · Fixed by #5370
Closed

Disabled widgets prevent focus from going to next widget #5359

lucasmerlin opened this issue Nov 8, 2024 · 0 comments · Fixed by #5370
Assignees
Labels
bug Something is broken egui

Comments

@lucasmerlin
Copy link
Collaborator

Describe the bug

Disabled widgets currently make it impossible to focus all widgets by pressing tab.

In this video I keep hitting tab:

Bildschirmaufnahme.2024-11-08.um.11.37.34.mov

Notice how Button 3 never receives focus.

To Reproduce
Minimal example:

    eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.button("Button 1");
            ui.button("Button 2");

            ui.add_enabled(false, Button::new("Button Disabled"));

            ui.button("Button 3");
        });
    })

Expected behavior
It should be possible to focus the widget after the disabled widget

@lucasmerlin lucasmerlin added bug Something is broken egui labels Nov 8, 2024
@emilk emilk added this to egui Nov 13, 2024
@emilk emilk moved this to Backlog in egui Nov 13, 2024
@lucasmerlin lucasmerlin self-assigned this Nov 14, 2024
lucasmerlin added a commit that referenced this issue Nov 14, 2024
lucasmerlin added a commit that referenced this issue Nov 14, 2024
emilk pushed a commit that referenced this issue Nov 26, 2024
- fixes #5359

For the test I added a `Harness::press_key` function. We should
eventually add these to kittest, probably via a trait one can implement
for the `Harness` but for now this should do.
@github-project-automation github-project-automation bot moved this from In review to Done in egui Nov 26, 2024
lucasmerlin added a commit that referenced this issue Nov 28, 2024
* Closes #686 
* Closes #839 
* #5370 should be merged before this
* [x] I have followed the instructions in the PR template

This adds modals to egui. 
This PR
- adds a new `Modal` struct
- adds `Memory::set_modal_layer` to limit focus to a layer and above
(used by the modal struct, but could also be used by custom modal
implementations)
- adds `Memory::allows_interaction` to check if a layer is behind a
modal layer, deprecating `Layer::allows_interaction`



Current problems:
- ~When a button is focused before the modal opens, it stays focused and
you also can't hit tab to focus the next widget. Seems like focus is
"stuck" on that widget until you hit escape. This might be related to
#5359 fixed!

Possible future improvements: 
- The titlebar from `window` should be made into a separate widget and
added to the modal
- The state whether the modal is open should be stored in egui
(optionally), similar to popup and menu. Ideally before this we would
refactor popup state to unify popup and menu

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant