diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 930c7096af0..578e759a632 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -107,6 +107,14 @@ [b]Note:[/b] This method will not be called when the script is attached to a [Control] node that already overrides its minimum size (e.g. [Label], [Button], [PanelContainer] etc.). It can only be used with most basic GUI nodes, like [Control], [Container], [Panel] etc. + + + + + Virtual method to be implemented by the user. Returns the tooltip text for the position [param at_position] in control's local coordinates, which will typically appear when the cursor is resting over this control. See [method get_tooltip]. + [b]Note:[/b] If this method returns an empty [String], no tooltip is displayed. + + @@ -532,8 +540,9 @@ - Returns the tooltip text [param at_position] in local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns [member tooltip_text]. - [b]Note:[/b] This method can be overridden to customize its behavior. If this method returns an empty [String], no tooltip is displayed. + Returns the tooltip text for the position [param at_position] in control's local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns [member tooltip_text]. + This method can be overridden to customize its behavior. See [method _get_tooltip]. + [b]Note:[/b] If this method returns an empty [String], no tooltip is displayed. diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index f78afed2c34..c6114eb74ee 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2876,6 +2876,10 @@ String Control::get_tooltip_text() const { } String Control::get_tooltip(const Point2 &p_pos) const { + String ret; + if (GDVIRTUAL_CALL(_get_tooltip, p_pos, ret)) { + return ret; + } return data.tooltip; } @@ -3417,6 +3421,7 @@ void Control::_bind_methods() { GDVIRTUAL_BIND(_has_point, "point"); GDVIRTUAL_BIND(_structured_text_parser, "args", "text"); GDVIRTUAL_BIND(_get_minimum_size); + GDVIRTUAL_BIND(_get_tooltip, "at_position"); GDVIRTUAL_BIND(_get_drag_data, "at_position"); GDVIRTUAL_BIND(_can_drop_data, "at_position", "data"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 2fb5d559b6b..da973783e99 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -345,6 +345,7 @@ protected: GDVIRTUAL1RC(bool, _has_point, Vector2) GDVIRTUAL2RC(TypedArray, _structured_text_parser, Array, String) GDVIRTUAL0RC(Vector2, _get_minimum_size) + GDVIRTUAL1RC(String, _get_tooltip, Vector2) GDVIRTUAL1RC(Variant, _get_drag_data, Vector2) GDVIRTUAL2RC(bool, _can_drop_data, Vector2, Variant)