diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml
index 2554528bcc..c493be6e91 100644
--- a/doc/classes/BaseButton.xml
+++ b/doc/classes/BaseButton.xml
@@ -75,7 +75,7 @@
If [code]true[/code], the button will highlight for a short amount of time when its shortcut is activated. If [code]false[/code] and [member toggle_mode] is [code]false[/code], the shortcut will activate without any visual feedback.
- If [code]true[/code], the button will add information about its shortcut in the tooltip.
+ If [code]true[/code], the button will add information about its shortcut in the tooltip. This includes the shortcut's events and its [member Resource.resource_name]. If both events and name are empty, the shortcut will not be included.
[b]Note:[/b] This property does nothing when the tooltip control is customized using [method Control._make_custom_tooltip].
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 5203e2188e..9f00d9e9fb 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -473,11 +473,21 @@ Control *BaseButton::make_custom_tooltip(const String &p_text) const {
if (control) {
return control;
}
- if (!shortcut_in_tooltip || shortcut.is_null() || !shortcut->has_valid_event()) {
+
+ if (!shortcut_in_tooltip || shortcut.is_null()) {
return nullptr; // Use the default tooltip label.
}
- String text = atr(shortcut->get_name()) + " (" + shortcut->get_as_text() + ")";
+ bool shortcut_has_events = shortcut->has_valid_event();
+ if (!shortcut_has_events && shortcut->get_name().is_empty()) {
+ return nullptr;
+ }
+
+ String text = atr(shortcut->get_name());
+ if (shortcut_has_events) {
+ text += " (" + shortcut->get_as_text() + ")";
+ }
+
if (!p_text.is_empty() && shortcut->get_name().nocasecmp_to(p_text) != 0) {
text += "\n" + atr(p_text);
}