Wait with showing tooltip until mouse has been still for 300ms (#3977)
You can change this with `style.interaction.tooltip_delay§
This commit is contained in:
parent
28d3c8e2b5
commit
d018265587
|
|
@ -886,8 +886,8 @@ impl PointerState {
|
||||||
|
|
||||||
/// How long has it been (in seconds) since the pointer was last moved?
|
/// How long has it been (in seconds) since the pointer was last moved?
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn time_since_last_movement(&self) -> f64 {
|
pub fn time_since_last_movement(&self) -> f32 {
|
||||||
self.time - self.last_move_time
|
(self.time - self.last_move_time) as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Was any pointer button pressed (`!down -> down`) this frame?
|
/// Was any pointer button pressed (`!down -> down`) this frame?
|
||||||
|
|
|
||||||
|
|
@ -499,13 +499,16 @@ impl Response {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.is_tooltip_open()
|
if !self.is_tooltip_open() {
|
||||||
&& self.ctx.input(|i| i.pointer.time_since_last_movement())
|
let time_til_tooltip = self.ctx.style().interaction.tooltip_delay
|
||||||
< self.ctx.style().interaction.tooltip_delay
|
- self.ctx.input(|i| i.pointer.time_since_last_movement());
|
||||||
{
|
|
||||||
// Keep waiting until the mouse has been still for a while
|
if 0.0 < time_til_tooltip {
|
||||||
self.ctx.request_repaint();
|
// Wait until the mouse has been still for a while
|
||||||
return false;
|
self.ctx
|
||||||
|
.request_repaint_after(std::time::Duration::from_secs_f32(time_til_tooltip));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't want tooltips of things while we are dragging them,
|
// We don't want tooltips of things while we are dragging them,
|
||||||
|
|
|
||||||
|
|
@ -719,7 +719,7 @@ pub struct Interaction {
|
||||||
pub show_tooltips_only_when_still: bool,
|
pub show_tooltips_only_when_still: bool,
|
||||||
|
|
||||||
/// Delay in seconds before showing tooltips after the mouse stops moving
|
/// Delay in seconds before showing tooltips after the mouse stops moving
|
||||||
pub tooltip_delay: f64,
|
pub tooltip_delay: f32,
|
||||||
|
|
||||||
/// Can you select the text on a [`crate::Label`] by default?
|
/// Can you select the text on a [`crate::Label`] by default?
|
||||||
pub selectable_labels: bool,
|
pub selectable_labels: bool,
|
||||||
|
|
@ -1128,7 +1128,7 @@ impl Default for Interaction {
|
||||||
resize_grab_radius_side: 5.0,
|
resize_grab_radius_side: 5.0,
|
||||||
resize_grab_radius_corner: 10.0,
|
resize_grab_radius_corner: 10.0,
|
||||||
show_tooltips_only_when_still: true,
|
show_tooltips_only_when_still: true,
|
||||||
tooltip_delay: 0.0,
|
tooltip_delay: 0.3,
|
||||||
selectable_labels: true,
|
selectable_labels: true,
|
||||||
multi_widget_text_select: true,
|
multi_widget_text_select: true,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue