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

Window contents can sometimes be affected by mouse interaction outside the window #4349

Open
s-nie opened this issue Apr 11, 2024 · 5 comments · May be fixed by #4388
Open

Window contents can sometimes be affected by mouse interaction outside the window #4349

s-nie opened this issue Apr 11, 2024 · 5 comments · May be fixed by #4388
Labels
bug Something is broken

Comments

@s-nie
Copy link
Contributor

s-nie commented Apr 11, 2024

egui version 0.27.2, also present on master

Describe the bug

Interactions outside a window can sometimes interact with elements inside the window if they allocate enough space.

To Reproduce

use eframe::{
    egui::{self, vec2},
    run_native, App,
};

struct TestApp;

impl App for TestApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        ctx.set_debug_on_hover(true);
        egui::Window::new("test")
            .scroll(true)
            .resizable(true)
            .title_bar(false)
            .show(ctx, |ui| {
                let _ = ui.allocate_space(vec2(1000.0, 100.0));
                ui.label("hello");
            });
    }
}

fn main() {
    run_native(
        "Test",
        Default::default(),
        Box::new(|_cc| Ok(Box::new(TestApp))),
    )
    .unwrap();
}

Expected behavior

The drag affects whatever is inside the window.

Screenshots

demo.mp4
@s-nie s-nie added the bug Something is broken label Apr 11, 2024
@rustbasic
Copy link
Contributor

rustbasic commented Apr 18, 2024

@emilk

It would be good for emilk to fix this.

This is a problem that has existed for a long time.

The area of egui::Window is recognized as large, so the buttons below that area cannot be clicked.

It will be easier to check the problem using the example below.

struct TestApp;

impl eframe::App for TestApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::Window::new("test")
            .scroll(true)
            .resizable(true)
            .show(ctx, |ui| {
                ui.label("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong");
                ui.collapsing(
                    "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
                    |_ui| {},
                );
            });

        egui::CentralPanel::default().show(ctx, |ui| {
            ctx.options_mut(|options| {
                options.tessellation_options.debug_paint_clip_rects = true;
            });
            ctx.settings_ui(ui);
        });
    }
}

fn main() {
    let _result = eframe::run_native(
        "Test",
        Default::default(),
        Box::new(|_cc| Box::new(TestApp)),
    );
}

@rustbasic
Copy link
Contributor

rustbasic commented Apr 20, 2024

@emilk

I will solve this and submit a Pull Request, soon.

@s-nie
Copy link
Contributor Author

s-nie commented Jun 3, 2024

I have updated the code to reproduce the issue, turns out that all that is needed is something that allocates space within a window.

@s-nie
Copy link
Contributor Author

s-nie commented Jun 3, 2024

@emilk It seems that the interact_rect of widgets does not get clipped with the parent window. Resizing that window updates the widget's interact_rect, although it still ends up being a bit too large, as seen in the video.

@emilk
Copy link
Owner

emilk commented Jun 3, 2024

Yup, somewhere the clip_rect set by ScrollArea is not properly intersected with the widget rect to produce the interact_rect.

@emilk emilk added this to the Next Patch Release milestone Jun 3, 2024
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
3 participants