Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix occasional flickering of pointer-tooltips #4788

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions crates/egui/src/containers/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,22 @@ pub fn show_tooltip_at_pointer<R>(
add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<R> {
ctx.input(|i| i.pointer.hover_pos()).map(|pointer_pos| {
show_tooltip_at(
let allow_placing_below = true;

// Add a small exclusion zone around the pointer to avoid tooltips
// covering what we're hovering over.
let mut exclusion_rect = Rect::from_center_size(pointer_pos, Vec2::splat(24.0));

// Keep the left edge of the tooltip in line with the cursor:
exclusion_rect.min.x = pointer_pos.x;

show_tooltip_at_dyn(
ctx,
parent_layer,
widget_id,
pointer_pos + vec2(16.0, 16.0),
add_contents,
allow_placing_below,
&exclusion_rect,
Box::new(add_contents),
)
})
}
Expand Down
Loading