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

[Tree] Allow disabling auto generated tooltip for TreeItem #97158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AThousandShips
Copy link
Member

The specifics of if the original behavior is desirable can be discussed, but this should be the most non-obtrusive approach to this, not disrupting existing behavior and just allowing you to configure this as wished

doc/classes/Tree.xml Outdated Show resolved Hide resolved
@WhalesState
Copy link
Contributor

Thank You.

@AThousandShips
Copy link
Member Author

AThousandShips commented Sep 18, 2024

Future improvement could involve checking the fit of the text, like is done in TabBar:

godot/scene/gui/tab_bar.cpp

Lines 326 to 337 in 694d3c2

String TabBar::get_tooltip(const Point2 &p_pos) const {
int tab_idx = get_tab_idx_at_point(p_pos);
if (tab_idx < 0) {
return Control::get_tooltip(p_pos);
}
if (tabs[tab_idx].tooltip.is_empty() && tabs[tab_idx].truncated) {
return tabs[tab_idx].text;
}
return tabs[tab_idx].tooltip;
}

But that'd involve some more complex changes here so will leave that to a future improvement

@WhalesState
Copy link
Contributor

WhalesState commented Sep 18, 2024

But that'd involve some more complex changes here so will leave that to a future improvement

Since we already can set a custom tooltip, it may look like this.

String ItemList::get_tooltip() {
   if (auto_tooltip || not_fit) {
        String item_tooltip = text;
        if (!tooltip.is_empty()) {
            item_tooltip += "\n" + tooltip;
        }
        return item_tooltip;
   }
  return tooltip;
}

@AThousandShips
Copy link
Member Author

I'll test some truncation code today and if it works out well I'll integrate it into this PR directly, but will keep it simple and match TabBar in that it won't combine the text and the tooltip and if you set a custom tooltip you'll have to do that yourself if you want it, the tooltip when set should be exactly what you set it as

@AThousandShips AThousandShips marked this pull request as draft September 19, 2024 06:38
@AThousandShips AThousandShips marked this pull request as ready for review September 20, 2024 18:35
@AThousandShips
Copy link
Member Author

Haven't gotten around to digging into using truncation here so taking this out of draft on its own and will look at adding truncation checks when I can

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

Successfully merging this pull request may close these issues.

TreeItem tooltip is repeating the item's text by default.
2 participants