Skip to content

Commit

Permalink
Fix interaction with widgets inside selectable rows of Table (#4077)
Browse files Browse the repository at this point in the history
* Closes #4047
  • Loading branch information
emilk authored Feb 20, 2024
1 parent 9096abd commit 4fc0c49
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/egui_extras/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl<'l> StripLayout<'l> {
);
}

let used_rect = self.cell(flags, max_rect, child_ui_id_source, add_cell_contents);
let child_ui = self.cell(flags, max_rect, child_ui_id_source, add_cell_contents);

let used_rect = child_ui.min_rect();

self.set_pos(max_rect);

Expand All @@ -156,7 +158,9 @@ impl<'l> StripLayout<'l> {
max_rect.union(used_rect)
};

let response = self.ui.allocate_rect(allocation_rect, self.sense);
self.ui.advance_cursor_after_rect(allocation_rect);

let response = child_ui.interact(max_rect, child_ui.id(), self.sense);

(used_rect, response)
}
Expand All @@ -183,13 +187,14 @@ impl<'l> StripLayout<'l> {
self.ui.allocate_rect(rect, Sense::hover());
}

/// Return the Ui to which the contents where added
fn cell(
&mut self,
flags: StripLayoutFlags,
rect: Rect,
child_ui_id_source: egui::Id,
add_cell_contents: impl FnOnce(&mut Ui),
) -> Rect {
) -> Ui {
let mut child_ui =
self.ui
.child_ui_with_id_source(rect, self.cell_layout, child_ui_id_source);
Expand All @@ -208,7 +213,7 @@ impl<'l> StripLayout<'l> {

add_cell_contents(&mut child_ui);

child_ui.min_rect()
child_ui
}

/// Allocate the rect in [`Self::ui`] so that the scrollview knows about our size
Expand Down

0 comments on commit 4fc0c49

Please sign in to comment.