egui icon indicating copy to clipboard operation
egui copied to clipboard

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

Open thmxv opened this issue 10 months ago • 2 comments

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 avatar Apr 09 '24 17:04 thmxv

@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");
                            }
                        });
                });
            });
        },
    );
}

rustbasic avatar Apr 19 '24 07:04 rustbasic

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.

thmxv avatar Apr 19 '24 15:04 thmxv