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?
|
||||
#[inline(always)]
|
||||
pub fn time_since_last_movement(&self) -> f64 {
|
||||
self.time - self.last_move_time
|
||||
pub fn time_since_last_movement(&self) -> f32 {
|
||||
(self.time - self.last_move_time) as f32
|
||||
}
|
||||
|
||||
/// Was any pointer button pressed (`!down -> down`) this frame?
|
||||
|
|
|
|||
|
|
@ -499,13 +499,16 @@ impl Response {
|
|||
}
|
||||
}
|
||||
|
||||
if !self.is_tooltip_open()
|
||||
&& self.ctx.input(|i| i.pointer.time_since_last_movement())
|
||||
< self.ctx.style().interaction.tooltip_delay
|
||||
{
|
||||
// Keep waiting until the mouse has been still for a while
|
||||
self.ctx.request_repaint();
|
||||
return false;
|
||||
if !self.is_tooltip_open() {
|
||||
let time_til_tooltip = self.ctx.style().interaction.tooltip_delay
|
||||
- self.ctx.input(|i| i.pointer.time_since_last_movement());
|
||||
|
||||
if 0.0 < time_til_tooltip {
|
||||
// Wait until the mouse has been still for a while
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -719,7 +719,7 @@ pub struct Interaction {
|
|||
pub show_tooltips_only_when_still: bool,
|
||||
|
||||
/// 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?
|
||||
pub selectable_labels: bool,
|
||||
|
|
@ -1128,7 +1128,7 @@ impl Default for Interaction {
|
|||
resize_grab_radius_side: 5.0,
|
||||
resize_grab_radius_corner: 10.0,
|
||||
show_tooltips_only_when_still: true,
|
||||
tooltip_delay: 0.0,
|
||||
tooltip_delay: 0.3,
|
||||
selectable_labels: true,
|
||||
multi_widget_text_select: true,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue