Handle tooltips so large that they cover the widget (#4623)
Previously a tooltip that overlapped the original widget would case an invisible or flickering tooltip. * Closes https://github.com/emilk/egui/issues/4616
This commit is contained in:
parent
bb8400853f
commit
cbb5d6aa93
|
|
@ -587,6 +587,17 @@ impl Response {
|
||||||
let is_tooltip_open = self.is_tooltip_open();
|
let is_tooltip_open = self.is_tooltip_open();
|
||||||
|
|
||||||
if is_tooltip_open {
|
if is_tooltip_open {
|
||||||
|
let (pointer_pos, pointer_vel) = self
|
||||||
|
.ctx
|
||||||
|
.input(|i| (i.pointer.hover_pos(), i.pointer.velocity()));
|
||||||
|
|
||||||
|
if let Some(pointer_pos) = pointer_pos {
|
||||||
|
if self.rect.contains(pointer_pos) {
|
||||||
|
// Handle the case of a big tooltip that covers the widget:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let tooltip_id = crate::next_tooltip_id(&self.ctx, self.id);
|
let tooltip_id = crate::next_tooltip_id(&self.ctx, self.id);
|
||||||
let layer_id = LayerId::new(Order::Tooltip, tooltip_id);
|
let layer_id = LayerId::new(Order::Tooltip, tooltip_id);
|
||||||
|
|
||||||
|
|
@ -603,14 +614,10 @@ impl Response {
|
||||||
// (i.e. click links that are in it).
|
// (i.e. click links that are in it).
|
||||||
if let Some(area) = AreaState::load(&self.ctx, tooltip_id) {
|
if let Some(area) = AreaState::load(&self.ctx, tooltip_id) {
|
||||||
let rect = area.rect();
|
let rect = area.rect();
|
||||||
let pointer_in_area_or_on_the_way_there = self.ctx.input(|i| {
|
|
||||||
if let Some(pos) = i.pointer.hover_pos() {
|
if let Some(pos) = pointer_pos {
|
||||||
rect.contains(pos)
|
let pointer_in_area_or_on_the_way_there = rect.contains(pos)
|
||||||
|| rect.intersects_ray(pos, i.pointer.velocity().normalized())
|
|| rect.intersects_ray(pos, pointer_vel.normalized());
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if pointer_in_area_or_on_the_way_there {
|
if pointer_in_area_or_on_the_way_there {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -618,6 +625,7 @@ impl Response {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fast early-outs:
|
// Fast early-outs:
|
||||||
if self.enabled {
|
if self.enabled {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue