Skip to content

Commit

Permalink
Make sure tooltips are interactable (#4649)
Browse files Browse the repository at this point in the history
…so you can't hover things underneath them.

* Better version of #4648
  • Loading branch information
emilk authored Jun 10, 2024
1 parent e2a127a commit ca36f3d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ impl Area {
}

/// If false, clicks goes straight through to what is behind us.
/// Good for tooltips etc.
///
/// Can be used for semi-invisible areas that the user should be able to click through.
///
/// Default: `true`.
#[inline]
pub fn interactable(mut self, interactable: bool) -> Self {
self.interactable = interactable;
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/containers/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn show_tooltip_at_avoid_dyn<'c, R>(
.pivot(pivot)
.fixed_pos(anchor)
.default_width(ctx.style().spacing.tooltip_width)
.interactable(false) // Only affects the actual area, i.e. clicking and dragging it. The content can still be interactive.
.sense(Sense::hover()) // don't click to bring to front
.show(ctx, |ui| {
// By default the text in tooltips aren't selectable.
// This means that most tooltips aren't interactable,
Expand Down
6 changes: 5 additions & 1 deletion crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ impl<'open> Window<'open> {
self
}

/// If `false` the window will be non-interactive.
/// If false, clicks goes straight through to what is behind us.
///
/// Can be used for semi-invisible areas that the user should be able to click through.
///
/// Default: `true`.
#[inline]
pub fn interactable(mut self, interactable: bool) -> Self {
self.area = self.area.interactable(interactable);
Expand Down
1 change: 0 additions & 1 deletion crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ fn menu_popup<'c, R>(
.kind(UiKind::Menu)
.order(Order::Foreground)
.fixed_pos(pos)
.interactable(true)
.default_width(ctx.style().spacing.menu_width)
.sense(Sense::hover());

Expand Down

0 comments on commit ca36f3d

Please sign in to comment.