diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index b9544c7c0d..41aebf9abf 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -92,6 +92,14 @@ Override this method to return a human-readable description of the position of the child [param node] in the custom container, added to the [member accessibility_name]. + + + + + Virtual method to be implemented by the user. Returns the cursor shape for the position [param at_position] in the control's local coordinates, which will typically be used while hovering over this control. See [method get_cursor_shape]. + If not overridden, defaults to [member mouse_default_cursor_shape]. + + @@ -129,7 +137,7 @@ - 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]. + Virtual method to be implemented by the user. Returns the tooltip text for the position [param at_position] in the 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] and [method _make_custom_tooltip] is not overridden, no tooltip is displayed. @@ -173,7 +181,7 @@ Virtual method to be implemented by the user. Returns whether the given [param point] is inside this control. - If not overridden, default behavior is checking if the point is within control's Rect. + If not overridden, default behavior is checking if the point is within the control's Rect. [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]Rect2(Vector2.ZERO, size).has_point(point)[/code]. @@ -417,9 +425,10 @@ - + - Returns the mouse cursor shape for this control when hovered over [param position] in local coordinates. For most controls, this is the same as [member mouse_default_cursor_shape], but some built-in controls implement more complex logic. + Returns the mouse cursor shape for this control when hovered over [param at_position] in local coordinates. For most controls, this is the same as [member mouse_default_cursor_shape], but some built-in controls implement more complex logic. + You can override [method _get_cursor_shape] to implement custom behavior for this method. @@ -603,8 +612,8 @@ - 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]. + Returns the tooltip text for the position [param at_position] in the control's local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns [member tooltip_text]. + You can override [method _get_tooltip] to implement custom behavior for this method. [b]Note:[/b] If this method returns an empty [String] and [method _make_custom_tooltip] is not overridden, no tooltip is displayed. diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2425642a98..c4bf59ab20 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -3183,6 +3183,10 @@ Control::CursorShape Control::get_default_cursor_shape() const { Control::CursorShape Control::get_cursor_shape(const Point2 &p_pos) const { ERR_READ_THREAD_GUARD_V(CURSOR_ARROW); + int ret; + if (GDVIRTUAL_CALL(_get_cursor_shape, p_pos, ret)) { + return (CursorShape)ret; + } return data.default_cursor; } @@ -4443,7 +4447,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Control::set_default_cursor_shape); ClassDB::bind_method(D_METHOD("get_default_cursor_shape"), &Control::get_default_cursor_shape); - ClassDB::bind_method(D_METHOD("get_cursor_shape", "position"), &Control::get_cursor_shape, DEFVAL(Point2())); + ClassDB::bind_method(D_METHOD("get_cursor_shape", "at_position"), &Control::get_cursor_shape, DEFVAL(Point2())); ClassDB::bind_method(D_METHOD("set_focus_neighbor", "side", "neighbor"), &Control::set_focus_neighbor); ClassDB::bind_method(D_METHOD("get_focus_neighbor", "side"), &Control::get_focus_neighbor); @@ -4758,6 +4762,8 @@ void Control::_bind_methods() { GDVIRTUAL_BIND(_drop_data, "at_position", "data"); GDVIRTUAL_BIND(_make_custom_tooltip, "for_text"); + GDVIRTUAL_BIND(_get_cursor_shape, "at_position"); + GDVIRTUAL_BIND(_accessibility_get_contextual_info); GDVIRTUAL_BIND(_get_accessibility_container_name, "node"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 6f30063664..ce29d07ede 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -441,6 +441,8 @@ protected: GDVIRTUAL2(_drop_data, Vector2, Variant) GDVIRTUAL1RC(Object *, _make_custom_tooltip, String) + GDVIRTUAL1RC(int, _get_cursor_shape, Vector2) + GDVIRTUAL0RC(String, _accessibility_get_contextual_info); GDVIRTUAL1RC(String, _get_accessibility_container_name, RequiredParam) @@ -703,7 +705,7 @@ public: void set_default_cursor_shape(CursorShape p_shape); CursorShape get_default_cursor_shape() const; - virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const; + virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2()) const; void set_clip_contents(bool p_clip); bool is_clipping_contents();