diff options
| -rw-r--r-- | doc/classes/Control.xml | 13 | ||||
| -rw-r--r-- | scene/gui/control.cpp | 5 | ||||
| -rw-r--r-- | scene/gui/control.h | 1 |
3 files changed, 17 insertions, 2 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 930c7096af..578e759a63 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. </description> </method> + <method name="_get_tooltip" qualifiers="virtual const"> + <return type="String" /> + <param index="0" name="at_position" type="Vector2" /> + <description> + 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. + </description> + </method> <method name="_gui_input" qualifiers="virtual"> <return type="void" /> <param index="0" name="event" type="InputEvent" /> @@ -532,8 +540,9 @@ <return type="String" /> <param index="0" name="at_position" type="Vector2" default="Vector2(0, 0)" /> <description> - 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. </description> </method> <method name="grab_click_focus"> diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index f78afed2c3..c6114eb74e 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 2fb5d559b6..da973783e9 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -345,6 +345,7 @@ protected: GDVIRTUAL1RC(bool, _has_point, Vector2) GDVIRTUAL2RC(TypedArray<Vector3i>, _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) |
