Skip to content

Commit

Permalink
Bug fix: ui.scope(…) is now equivalent to ui.allocate_space(…) WRT IDs
Browse files Browse the repository at this point in the history
Before a disabled and enabled button would leave the parent ui
in different states, which lead to a bug where a slider drag could be
aborted if it caused a button before it to switch between enabled
and disabled.

Repro: dragging slider in "Manual Layout Test"
  • Loading branch information
emilk committed Jun 24, 2021
1 parent 9007890 commit 6e3604e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,9 @@ impl Ui {
/// ```
pub fn scope<R>(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
let child_rect = self.available_rect_before_wrap();
let next_auto_id_source = self.next_auto_id_source;
let mut child_ui = self.child_ui(child_rect, *self.layout());
self.next_auto_id_source = next_auto_id_source; // HACK: we want `scope` to only increment this once, so that `ui.scope` is equivalent to `ui.allocate_space`.
let ret = add_contents(&mut child_ui);
let response = self.allocate_rect(child_ui.min_rect(), Sense::hover());
InnerResponse::new(ret, response)
Expand Down

0 comments on commit 6e3604e

Please sign in to comment.