Make sure tooltips are interactable (#4649)

…so you can't hover things underneath them.

* Better version of https://github.com/emilk/egui/pull/4648
This commit is contained in:
Emil Ernerfeldt 2024-06-10 14:05:06 +02:00 committed by GitHub
parent e2a127a381
commit ca36f3df63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 4 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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());