Skip to content

Support on hover tooltip that is noninteractable even with interactable content#5543

Merged
emilk merged 1 commit intoemilk:mainfrom
PPakalns:noninteractive_tooltip
Sep 9, 2025
Merged

Support on hover tooltip that is noninteractable even with interactable content#5543
emilk merged 1 commit intoemilk:mainfrom
PPakalns:noninteractive_tooltip

Conversation

@PPakalns
Copy link
Copy Markdown
Contributor

@PPakalns
Copy link
Copy Markdown
Contributor Author

Tested in real use case. Greatly reduces flickering for "preview" tooltips that may contain interactable widgets.

Use case: "Preview" of the page/window that will be opened if the button is pressed.

@github-actions
Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/5543-noninteractivetooltip
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@grtlr
Copy link
Copy Markdown
Collaborator

grtlr commented Jan 3, 2025

@emilk I ran into a related problem: rerun-io/rerun#8568

It seems like the current logic in should_show_hover_ui does not take into account that the tooltip is drawn in relation to the pointer position. Because of this, the tooltip always remains open since it's shifted at every frame.

In the case of the Rerun graph view, we can simply call on_hover_ui instead of on_hover_ui_at_pointer: rerun-io/rerun#8573

@PPakalns PPakalns force-pushed the noninteractive_tooltip branch from 942690e to ebbf493 Compare January 16, 2025 17:20
@PPakalns
Copy link
Copy Markdown
Contributor Author

Resolved conflicts.

@PPakalns PPakalns force-pushed the noninteractive_tooltip branch from ebbf493 to 37240f1 Compare January 22, 2025 12:01
@PPakalns
Copy link
Copy Markdown
Contributor Author

Updated against newest master to rerun checks that failed due to incorrectly configured github pipeline action.

Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the need for this functionality, but I think it's time to make a builder for tooltips so that we don't get this combinatorial explosion of tooltip methods

@PPakalns
Copy link
Copy Markdown
Contributor Author

PPakalns commented Jan 27, 2025

I appreciate the need for this functionality, but I think it's time to make a builder for tooltips so that we don't get this combinatorial explosion of tooltip methods

@emilk
I can implement this using builder pattern.

To make sure that I decide the right design for this, feel free to correct me:

Currently we have methods:

on_hover_ui
on_hover_ui_at_pointer
on_disabled_hover_ui

And this PR wants to add parameter to configure if hover (tooltip) ui is interactable.

I could replace these methods with one simple method:

on_hover_ui(HoverBuilder)

Where HoverBuilder has configurable options:

  1. Show at pointer
  2. Show if UI is enabled / disabled
  3. Should hover UI be kept open if mouse moves over it (Is it interactable, can be hovered over)

Does this design seems OK?

@lucasmerlin
Copy link
Copy Markdown
Collaborator

lucasmerlin commented Feb 18, 2025

@PPakalns we now have a unified Tooltip struct, so now it should be straightforward to add as an option there! See #5713 for more info. I've marked this as draft for now, feel free to undraft once this is rebased on the Tooltip struct!

@lucasmerlin lucasmerlin marked this pull request as draft February 18, 2025 17:09
@PPakalns PPakalns force-pushed the noninteractive_tooltip branch from 37240f1 to 8a9c9a0 Compare July 24, 2025 08:51
@PPakalns
Copy link
Copy Markdown
Contributor Author

@lucasmerlin

PR is ready for review!

Refactored code. Removed duplicated on_hover_ui family of functions.
If users want their own custom logic without tooltip interactions. They can construct egui::Tooltip as it is done in egui::Tooltip::for_enabled method and then modify logic for their needs.

@PPakalns PPakalns requested a review from emilk July 24, 2025 08:58
@PPakalns PPakalns marked this pull request as ready for review July 24, 2025 10:07
@lucasmerlin lucasmerlin added feature New feature or request egui labels Jul 24, 2025
Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I guess it's not very convenient to use this, but since it handles an edge case it should be fine.

@emilk emilk merged commit 2afc43c into emilk:main Sep 9, 2025
45 of 47 checks passed
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

egui feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Noninteractive tooltip with any content (on_hover_ui)

4 participants