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

ScrollArea (and all scoll-able widgets) scroll-able even when not enabled #4341

Closed
thmxv opened this issue Apr 9, 2024 · 2 comments · Fixed by #4457
Closed

ScrollArea (and all scoll-able widgets) scroll-able even when not enabled #4341

thmxv opened this issue Apr 9, 2024 · 2 comments · Fixed by #4457
Labels
bug Something is broken

Comments

@thmxv
Copy link

thmxv commented Apr 9, 2024

Describe the bug
I try to disable the whole main window when a modal window is visible on top but of the disabled widget on the main window, the ScrollArea widgets are still scroll-able.

This issues affects all the scroll-able widgets (egui-extras::TableBody for example) not only the ScrollArea.

In 0.26 the issue was impacting all the drag-able widgets also but this is fixed in 0.27 and still is in git master.

To Reproduce

fn main() {
    let mut main_enabled = false;

    let _ = eframe::run_simple_native(
        "Issue test",
        eframe::NativeOptions::default(),
        move |ctx, _frame| {
            egui::CentralPanel::default().show(ctx, |ui| {
                ui.checkbox(&mut main_enabled, "Enabled");
                ui.separator();
                ui.add_enabled_ui(main_enabled, |ui| {
                    egui::ScrollArea::vertical().show(ui, |ui| {
                        for _ in 0..100 {
                            ui.label("some text");
                        }
                    });
                });
            });
        },
    );
}

Expected behavior
I expect the scroll-able widgets to not be able to be interacted with at all when disabled.

Desktop (please complete the following information):

  • OS: Linux 6.6.25 LTS
@thmxv thmxv added the bug Something is broken label Apr 9, 2024
@rustbasic
Copy link
Contributor

rustbasic commented Apr 19, 2024

@thmxv

I think you should add '.enable_scrolling(main_enabled)', try that.

fn main() {
    let mut main_enabled = false;

    let _ = eframe::run_simple_native(
        "Issue test",
        eframe::NativeOptions::default(),
        move |ctx, _frame| {
            egui::CentralPanel::default().show(ctx, |ui| {
                ui.checkbox(&mut main_enabled, "Enabled");
                ui.separator();
                ui.add_enabled_ui(main_enabled, |ui| {
                    egui::ScrollArea::vertical()
                        .enable_scrolling(main_enabled)
                        .show(ui, |ui| {
                            for _ in 0..100 {
                                ui.label("some text");
                            }
                        });
                });
            });
        },
    );
}

@thmxv
Copy link
Author

thmxv commented Apr 19, 2024

This works, for ScrollArea and this demo code. But it is a bit unpractical in reality. In the case of opening a modal window/dialog and wanting to disable everything on the main window underneath:

  • There is a need to add .enable_scrolling(ui.is_enabled()) to every ScrollArea in the main window
  • For some widgets (like egui_extras.Table and egui_dock.TabViewer and possibly others) there is no equivalent API and this is not possible.

Anyway, this is low priority and only a weird behavior not a serious bug. So feel free to close if this is the wanted behavior in disabled UI. Also thanks for the help.

emilk pushed a commit that referenced this issue May 10, 2024
…4457)

## Summary

This PR modifies `ScrollArea` and `Plot` to disable their interactions
when the UI is disabled.

## Changes

- Interaction with `ScrollArea` in `egui` is disabled when the UI is
disabled.
- Interaction with `Plot` in `egui_plot` is disabled when the UI is
disabled.
- These changes ensure that `ScrollArea` and `Plot` behave consistently
with the rest of the UI, preventing them from responding to user input
when the UI is in a disabled state.

## Impact

This PR enhances the consistency of `egui`'s UI behavior by ensuring
that all elements, including `ScrollArea` and `Plot`, respect the UI's
disabled state. This prevents unexpected interactions when the UI is
disabled.

Closes #4341
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
…milk#4457)

## Summary

This PR modifies `ScrollArea` and `Plot` to disable their interactions
when the UI is disabled.

## Changes

- Interaction with `ScrollArea` in `egui` is disabled when the UI is
disabled.
- Interaction with `Plot` in `egui_plot` is disabled when the UI is
disabled.
- These changes ensure that `ScrollArea` and `Plot` behave consistently
with the rest of the UI, preventing them from responding to user input
when the UI is in a disabled state.

## Impact

This PR enhances the consistency of `egui`'s UI behavior by ensuring
that all elements, including `ScrollArea` and `Plot`, respect the UI's
disabled state. This prevents unexpected interactions when the UI is
disabled.

Closes emilk#4341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants