Allow Control
to show custom tooltip when tooltip text is empty
Co-Authored-By: bruvzg <7645683+bruvzg@users.noreply.github.com>
This commit is contained in:
parent
842f982397
commit
6f35915622
1 changed files with 5 additions and 5 deletions
|
@ -1448,7 +1448,11 @@ void Viewport::_gui_show_tooltip() {
|
||||||
&tooltip_owner);
|
&tooltip_owner);
|
||||||
gui.tooltip_text = gui.tooltip_text.strip_edges();
|
gui.tooltip_text = gui.tooltip_text.strip_edges();
|
||||||
|
|
||||||
if (gui.tooltip_text.is_empty()) {
|
// Controls can implement `make_custom_tooltip` to provide their own tooltip.
|
||||||
|
// This should be a Control node which will be added as child to a TooltipPanel.
|
||||||
|
Control *base_tooltip = tooltip_owner ? tooltip_owner->make_custom_tooltip(gui.tooltip_text) : nullptr;
|
||||||
|
|
||||||
|
if (gui.tooltip_text.is_empty() && !base_tooltip) {
|
||||||
return; // Nothing to show.
|
return; // Nothing to show.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1469,10 +1473,6 @@ void Viewport::_gui_show_tooltip() {
|
||||||
// Ensure no opaque background behind the panel as its StyleBox can be partially transparent (e.g. corners).
|
// Ensure no opaque background behind the panel as its StyleBox can be partially transparent (e.g. corners).
|
||||||
panel->set_transparent_background(true);
|
panel->set_transparent_background(true);
|
||||||
|
|
||||||
// Controls can implement `make_custom_tooltip` to provide their own tooltip.
|
|
||||||
// This should be a Control node which will be added as child to a TooltipPanel.
|
|
||||||
Control *base_tooltip = tooltip_owner->make_custom_tooltip(gui.tooltip_text);
|
|
||||||
|
|
||||||
// If no custom tooltip is given, use a default implementation.
|
// If no custom tooltip is given, use a default implementation.
|
||||||
if (!base_tooltip) {
|
if (!base_tooltip) {
|
||||||
gui.tooltip_label = memnew(Label);
|
gui.tooltip_label = memnew(Label);
|
||||||
|
|
Loading…
Reference in a new issue