Skip to content

Commit

Permalink
Disable interaction for ScrollArea and Plot when UI is disabled (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
varphone authored May 10, 2024
1 parent 27a22f9 commit 11fa9cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ impl ScrollArea {
} = self;

let ctx = ui.ctx().clone();
let scrolling_enabled = scrolling_enabled && ui.is_enabled();

let id_source = id_source.unwrap_or_else(|| Id::new("scroll_area"));
let id = ui.make_persistent_id(id_source);
Expand Down
5 changes: 5 additions & 0 deletions crates/egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ impl Plot {
sense,
} = self;

// Disable interaction if ui is disabled.
let allow_zoom = allow_zoom.and(ui.is_enabled());
let allow_drag = allow_drag.and(ui.is_enabled());
let allow_scroll = allow_scroll.and(ui.is_enabled());

// Determine position of widget.
let pos = ui.available_rect_before_wrap().min;
// Determine size of widget.
Expand Down

0 comments on commit 11fa9cc

Please sign in to comment.