Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow showing tooltips with a slight time delay #3232

Closed
stfnp opened this issue Aug 10, 2023 · 2 comments · Fixed by #3245
Closed

Allow showing tooltips with a slight time delay #3232

stfnp opened this issue Aug 10, 2023 · 2 comments · Fixed by #3245

Comments

@stfnp
Copy link

stfnp commented Aug 10, 2023

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.

@YgorSouza
Copy link
Contributor

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.

@emilk
Copy link
Owner

emilk commented Aug 12, 2023

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

YgorSouza added a commit to YgorSouza/egui that referenced this issue Aug 12, 2023
Similar to the show_tooltips_only_when_still option, but allows the user
to configure a specific delay in seconds, and also makes the tooltip
disappear if the mouse is moved again.

Closes emilk#3232
emilk added a commit that referenced this issue Aug 15, 2023
* Add tooltip_delay option

Similar to the show_tooltips_only_when_still option, but allows the user
to configure a specific delay in seconds, and also makes the tooltip
disappear if the mouse is moved again.

Closes #3232

* Update crates/egui/src/response.rs

Co-authored-by: Emil Ernerfeldt <[email protected]>

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants