mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
Fix occational flickering of pointer-tooltips (#4788)
Affects uses of `on_hover_ui_at_pointer` and `show_tooltip_at_pointer`
This commit is contained in:
@@ -79,12 +79,22 @@ pub fn show_tooltip_at_pointer<R>(
|
|||||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
) -> Option<R> {
|
) -> Option<R> {
|
||||||
ctx.input(|i| i.pointer.hover_pos()).map(|pointer_pos| {
|
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,
|
ctx,
|
||||||
parent_layer,
|
parent_layer,
|
||||||
widget_id,
|
widget_id,
|
||||||
pointer_pos + vec2(16.0, 16.0),
|
allow_placing_below,
|
||||||
add_contents,
|
&exclusion_rect,
|
||||||
|
Box::new(add_contents),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user