Closed stfnp closed 1 year ago
It could have a field in Style like animation_time, or even just use animation_time
itself, if it seems more consistent. Then it would be a matter of keeping track of when the last pointer movement occurred, and only showing the tooltip if it's been longer than the specified time. One thing to note is that when the pointer is not moving, normally the UI does not repaint, so egui has to treat this delayed tooltip like it treats the other animations for it to work properly.
Another feature that other UI frameworks have is that the tooltip disappears when you press a key, and doesn't reappear until you move the pointer again. But that could probably be a separate issue, if egui users are interested in it.
I think it makes most sense with a global tootlip_delay
option in Style
.
You can follow the bread-crumbs of the similar show_tooltips_only_when_still
options. We'll need to add a last_move_time: f64
to PointerState
to implement this
The current way to show a tooltip, as far as I can tell, is to use on_hover_text and friends.
These methods show a custom tooltip almost immediately when an item is hovered. This might be desired in some cases, but it can also be distracting because the tooltip is shown even when the mouse just quickly crosses an item. That's why tooltips are usually shown after a small time delay so that they only show up when actually needed.
I have no idea about the implementation, but I think it would be nice to have some methods like
on_hover_text_delayed
or similar that show a tooltip only after a certain time of continuous hovering. The time delay could be part of the style.