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

Add text tooltip for TabBar & TabContainer #9252

Closed
4d49 opened this issue Mar 7, 2024 · 0 comments · Fixed by godotengine/godot#89247
Closed

Add text tooltip for TabBar & TabContainer #9252

4d49 opened this issue Mar 7, 2024 · 0 comments · Fixed by godotengine/godot#89247
Milestone

Comments

@4d49
Copy link

4d49 commented Mar 7, 2024

Describe the project you are working on

Data editing tool.

Describe the problem or limitation you are having in your project

Currently, TabBar does not show text tooltips for tabs. It would be useful to be able to set custom text tooltips.
изображение

Also it would be useful to display a text tooltip with the tab title if the max tab width limit is set and the title does not fit.
изображение

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Need to override the get_tooltip method and add two new set_tab_tooltip & get_tab_tooltip methods to TabBar.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

String TabBar::get_tooltip(const Point2 &p_pos) const {
	for (int i = 0; i < tabs.size(); i++) {
		if (tabs[i].hidden) {
			continue;
		}

		if (get_tab_rect(i).has_point(p_pos)) {
			if (tabs[i].tooltip.is_empty()) {
				return tabs[i].text;
			}

			return tabs[i].tooltip;
		}
	}

	return Control::get_tooltip(p_pos);
}

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes. It is possible to inherit from TabBar and override the _get_tooltip method.

Is there a reason why this should be core and not an add-on in the asset library?

No.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants