Skip to content

Commit

Permalink
Fix tooltip getting stuck if its selection despawns
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Jul 27, 2024
1 parent a185ac1 commit f57f0cf
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/ui/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ impl Configure for Tooltip {
update_tooltip_text,
)
.in_set(UpdateSet::SyncLate)
.after(detect_tooltip_hover)
.run_if(on_event::<TooltipHover>()),
);
app.add_systems(
Expand Down Expand Up @@ -184,12 +183,11 @@ struct TooltipHover(Option<Entity>);
impl Configure for TooltipHover {
fn configure(app: &mut App) {
app.add_event::<TooltipHover>();
app.add_systems(Update, detect_tooltip_hover.in_set(UpdateSet::SyncLate));
app.add_systems(Update, detect_tooltip_hover.in_set(UpdateSet::RecordInput));
}
}

fn detect_tooltip_hover(
entities: &Entities,
mut events: EventWriter<TooltipHover>,
tooltip_root: Res<TooltipRoot>,
tooltip_query: Query<&Selection>,
Expand All @@ -206,15 +204,13 @@ fn detect_tooltip_hover(
continue;
}

// Show tooltip.
// Hovering something new: Update tooltip.
if selection.0 != entity {
events.send(TooltipHover(Some(entity)));
}
return;
}

// Hide tooltip.
if entities.contains(selection.0) {
events.send(TooltipHover(None));
}
// Not hovering anything: Hide tooltip.
events.send(TooltipHover(None));
}

0 comments on commit f57f0cf

Please sign in to comment.