Is your feature request related to a problem? Please describe.
AFAIK, there is no way to show a tooltip when hovering the per-tab "close" button (x) or the "add tab" button (+).
Tooltips already exist in other parts of the library:
show_tab_name_on_hover for tab labels
LeafTranslations::close_button_disabled_tooltip for the disabled close-all button
show_secondary_button_hint for secondary buttons on tab bars
But neither the close button on individual tabs nor the add button expose their egui::Response and no TabViewer callback gives access to it. You cannot attach .on_hover_text() or .on_hover_ui() to these elements.
Describe the solution you'd like
Add two new defaulted methods to TabViewer:
/// Optional tooltip text shown when hovering the close button of the given tab.
fn close_button_tooltip(&mut self, _tab: &mut Self::Tab) -> Option<String> {
None
}
/// Optional tooltip text shown when hovering the add tab button.
fn add_button_tooltip(&mut self) -> Option<String> {
None
}
Internally, the library would call response.on_hover_text(text) when the method returns Some.
This follows the same TabViewer callback pattern used elsewhere and does not seems to break any existing API.
Describe alternatives you've considered
- Using
on_tab_button to get the tab Response, estimating the close button position from the tab rect (offset by style padding, button size...), and calling egui::show_tooltip_at when the pointer falls inside that computed region.
- Placing a transparent interactive widget on top of the close or add button rect to get a
Response that .on_hover_text() can be chained on.
Both break when internal layout details (button size, padding, alignment) change between versions and are really dirty.
Additional context
In my case, clicking on the (+) button opens a popup dialog with a form to generate the next tab (which contains some kind of plots) so having a helper text on hover to explain what it will do would be ideal.
Also, on_tab_button (added in #93 already gives access to the tab label response. The close and add buttons are the only tab bar elements still missing this.
If this is a feature you would be interested to have I can work on a PR for it.
Is your feature request related to a problem? Please describe.
AFAIK, there is no way to show a tooltip when hovering the per-tab "close" button (
x) or the "add tab" button (+).Tooltips already exist in other parts of the library:
show_tab_name_on_hoverfor tab labelsLeafTranslations::close_button_disabled_tooltipfor the disabled close-all buttonshow_secondary_button_hintfor secondary buttons on tab barsBut neither the close button on individual tabs nor the add button expose their
egui::Responseand noTabViewercallback gives access to it. You cannot attach.on_hover_text()or.on_hover_ui()to these elements.Describe the solution you'd like
Add two new defaulted methods to
TabViewer:Internally, the library would call
response.on_hover_text(text)when the method returnsSome.This follows the same
TabViewercallback pattern used elsewhere and does not seems to break any existing API.Describe alternatives you've considered
on_tab_buttonto get the tabResponse, estimating the close button position from the tab rect (offset by style padding, button size...), and callingegui::show_tooltip_atwhen the pointer falls inside that computed region.Responsethat.on_hover_text()can be chained on.Both break when internal layout details (button size, padding, alignment) change between versions and are really dirty.
Additional context
In my case, clicking on the (
+) button opens a popup dialog with a form to generate the next tab (which contains some kind of plots) so having a helper text on hover to explain what it will do would be ideal.Also,
on_tab_button(added in #93 already gives access to the tab label response. The close and add buttons are the only tab bar elements still missing this.If this is a feature you would be interested to have I can work on a PR for it.