Support on hover tooltip that is noninteractable even with interactable content (#5543)
This commit is contained in:
parent
75b50c90e8
commit
2afc43c0ec
|
|
@ -72,7 +72,7 @@ impl Tooltip<'_> {
|
||||||
let mut tooltip = Self::for_widget(response);
|
let mut tooltip = Self::for_widget(response);
|
||||||
tooltip.popup = tooltip
|
tooltip.popup = tooltip
|
||||||
.popup
|
.popup
|
||||||
.open(response.enabled() && Self::should_show_tooltip(response));
|
.open(response.enabled() && Self::should_show_tooltip(response, true));
|
||||||
tooltip
|
tooltip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ impl Tooltip<'_> {
|
||||||
let mut tooltip = Self::for_widget(response);
|
let mut tooltip = Self::for_widget(response);
|
||||||
tooltip.popup = tooltip
|
tooltip.popup = tooltip
|
||||||
.popup
|
.popup
|
||||||
.open(!response.enabled() && Self::should_show_tooltip(response));
|
.open(!response.enabled() && Self::should_show_tooltip(response, true));
|
||||||
tooltip
|
tooltip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,7 +211,10 @@ impl Tooltip<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Should we show a tooltip for this response?
|
/// Should we show a tooltip for this response?
|
||||||
pub fn should_show_tooltip(response: &Response) -> bool {
|
///
|
||||||
|
/// Argument `allow_interactive_tooltip` controls whether mouse can interact with tooltip that
|
||||||
|
/// contains interactive widgets
|
||||||
|
pub fn should_show_tooltip(response: &Response, allow_interactive_tooltip: bool) -> bool {
|
||||||
if response.ctx.memory(|mem| mem.everything_is_visible()) {
|
if response.ctx.memory(|mem| mem.everything_is_visible()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +267,8 @@ impl Tooltip<'_> {
|
||||||
let tooltip_id = Self::next_tooltip_id(&response.ctx, response.id);
|
let tooltip_id = Self::next_tooltip_id(&response.ctx, response.id);
|
||||||
let tooltip_layer_id = LayerId::new(Order::Tooltip, tooltip_id);
|
let tooltip_layer_id = LayerId::new(Order::Tooltip, tooltip_id);
|
||||||
|
|
||||||
let tooltip_has_interactive_widget = response.ctx.viewport(|vp| {
|
let tooltip_has_interactive_widget = allow_interactive_tooltip
|
||||||
|
&& response.ctx.viewport(|vp| {
|
||||||
vp.prev_pass
|
vp.prev_pass
|
||||||
.widgets
|
.widgets
|
||||||
.get_layer(tooltip_layer_id)
|
.get_layer(tooltip_layer_id)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue