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

Show String properties' text in a tooltip in the inspector #76231

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

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Apr 18, 2023

This allows previewing single-line or multipline strings that are too long too fit within the box in the inspector.

I wonder if it's possible to only show the tooltip if the text doesn't fully fit within the box. @bruvzg Is there a way we can detect this while taking the font size and advance into account (for both LineEdit and TextEdit)?

Testing project: test_inspector_text_tooltip.zip

Preview

Screenshot_20230418_234734

@Yagich
Copy link
Contributor

Yagich commented Apr 18, 2023

How does this work with properties that have doc comments?

@Calinou
Copy link
Member Author

Calinou commented Apr 18, 2023

How does this work with properties that have doc comments?

The value's tooltip is shown when hovering the value. The documentation is only shown when hovering the name, like before. (This also applies to properties of types other than String.)

@MewPurPur
Copy link
Contributor

I wonder if it's possible to only show the tooltip if the text doesn't fully fit within the box.

I don't think that's a necessary complication, all types always show their value as tooltips.

@dustdfg

This comment was marked as off-topic.

@Calinou Calinou requested a review from a team as a code owner October 28, 2024 17:16
@Calinou
Copy link
Member Author

Calinou commented Oct 28, 2024

Rebased and tested again, it works as expected.

@Mickeon Mickeon modified the milestones: 4.x, 4.4 Oct 28, 2024
@Mickeon
Copy link
Contributor

Mickeon commented Oct 28, 2024

Moving this to 4.4 as it should've been a long time coming.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 28, 2024

I'm not sure if simply displaying everything is a good idea
image
It needs some sort of autowrapping/scroll.

@Calinou
Copy link
Member Author

Calinou commented Nov 2, 2024

I've trimmed the tooltip to the first 100 characters, so it should no longer get very long now.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

Functionality-wise looks ok.

This allows previewing single-line or multipline strings
that are too long too fit within the box in the inspector.
@@ -103,6 +107,7 @@ void EditorPropertyText::update_property() {
if (text->get_text() != s) {
int caret = text->get_caret_column();
text->set_text(s);
text->set_tooltip_text(s.left(TOOLTIP_MAX_LENGTH).strip_edges() + String((s.length() > TOOLTIP_MAX_LENGTH) ? "..." : ""));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
text->set_tooltip_text(s.left(TOOLTIP_MAX_LENGTH).strip_edges() + String((s.length() > TOOLTIP_MAX_LENGTH) ? "..." : ""));
text->set_tooltip_text(get_tooltip_string(s));

Unless something is special about this case

emit_changed(get_edited_property(), big_text->get_text(), "", true);
}

void EditorPropertyMultilineText::_text_changed() {
text->set_tooltip_text(text->get_text().left(TOOLTIP_MAX_LENGTH).strip_edges() + String((text->get_text().length() > TOOLTIP_MAX_LENGTH) ? "..." : ""));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
text->set_tooltip_text(text->get_text().left(TOOLTIP_MAX_LENGTH).strip_edges() + String((text->get_text().length() > TOOLTIP_MAX_LENGTH) ? "..." : ""));
text->set_tooltip_text(get_tooltip_string(text->get_text()));

Ditto

@@ -181,6 +190,7 @@ void EditorPropertyMultilineText::update_property() {
String t = get_edited_property_value();
if (text->get_text() != t) {
text->set_text(t);
text->set_tooltip_text(t.left(TOOLTIP_MAX_LENGTH).strip_edges() + String((t.length() > TOOLTIP_MAX_LENGTH) ? "..." : ""));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
text->set_tooltip_text(t.left(TOOLTIP_MAX_LENGTH).strip_edges() + String((t.length() > TOOLTIP_MAX_LENGTH) ? "..." : ""));
text->set_tooltip_text(get_tooltip_string(t));

Ditto

Copy link
Member

Choose a reason for hiding this comment

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

These should be unnecessary now assuming the above are replaced

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.

7 participants