From aff5b413aaa2d6e40dced37655962fc473d992d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?=
<7645683+bruvzg@users.noreply.github.com>
Date: Wed, 21 May 2025 09:34:12 +0300
Subject: [PATCH] Move some accessibility properties from Node to Control
---
doc/classes/Control.xml | 28 +++++++
doc/classes/Node.xml | 28 -------
doc/classes/Window.xml | 6 ++
scene/gui/control.cpp | 168 ++++++++++++++++++++++++++++++++++++++++
scene/gui/control.h | 37 +++++++++
scene/main/node.cpp | 167 +--------------------------------------
scene/main/node.h | 31 --------
scene/main/window.cpp | 42 +++++++++-
scene/main/window.h | 8 ++
9 files changed, 289 insertions(+), 226 deletions(-)
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index c533871c057..b135fda4a06 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -85,6 +85,13 @@
[/codeblocks]
+
+
+
+
+ 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].
+
+
@@ -962,6 +969,27 @@
+
+ The paths to the nodes which are controlled by this node.
+
+
+ The paths to the nodes which are describing this node.
+
+
+ The human-readable node description that is reported to assistive apps.
+
+
+ The paths to the nodes which this node flows into.
+
+
+ The paths to the nodes which label this node.
+
+
+ The mode with which a live region updates. A live region is a [Node] that is updated as a result of an external event when the user's focus may be elsewhere.
+
+
+ The human-readable node name that is reported to assistive apps.
+
Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience.
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 84ed5a565a9..b7d2939e9c5 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -43,13 +43,6 @@
Returning an empty array produces no warnings.
-
-
-
-
- Return a human-readable description of the position of [param node] child in the custom container, added to the node name.
-
-
@@ -1035,27 +1028,6 @@
-
- The list of nodes which are controlled by this node.
-
-
- The list of nodes which are describing this node.
-
-
- The human-readable node description that is reported to assistive apps.
-
-
- The list of nodes which this node flows into.
-
-
- The list of nodes which label this node.
-
-
- Live region update mode, a live region is [Node] that is updated as a result of an external event when user focus may be elsewhere.
-
-
- The human-readable node name that is reported to assistive apps.
-
Defines if any text should automatically change to its translated version depending on the current locale (for nodes such as [Label], [RichTextLabel], [Window], etc.). Also decides if the node's strings should be parsed for POT generation.
[b]Note:[/b] For the root node, auto translate mode can also be set via [member ProjectSettings.internationalization/rendering/root_node_auto_translate].
diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml
index dd8d78180db..7c803902145 100644
--- a/doc/classes/Window.xml
+++ b/doc/classes/Window.xml
@@ -578,6 +578,12 @@
+
+ The human-readable node description that is reported to assistive apps.
+
+
+ The human-readable node name that is reported to assistive apps.
+
If [code]true[/code], the window will be on top of all other windows. Does not work if [member transient] is enabled.
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 7bf9deca20b..bb02638bb0c 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2120,6 +2120,100 @@ void Control::accessibility_drop() {
queue_accessibility_update();
}
+String Control::get_accessibility_container_name(const Node *p_node) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_get_accessibility_container_name, p_node, ret)) {
+ } else if (data.parent_control) {
+ ret = data.parent_control->get_accessibility_container_name(this);
+ }
+ return ret;
+}
+
+void Control::set_accessibility_name(const String &p_name) {
+ ERR_THREAD_GUARD
+ if (data.accessibility_name != p_name) {
+ data.accessibility_name = p_name;
+ queue_accessibility_update();
+ update_configuration_warnings();
+ }
+}
+
+String Control::get_accessibility_name() const {
+ return tr(data.accessibility_name);
+}
+
+void Control::set_accessibility_description(const String &p_description) {
+ ERR_THREAD_GUARD
+ if (data.accessibility_description != p_description) {
+ data.accessibility_description = p_description;
+ queue_accessibility_update();
+ }
+}
+
+String Control::get_accessibility_description() const {
+ return tr(data.accessibility_description);
+}
+
+void Control::set_accessibility_live(DisplayServer::AccessibilityLiveMode p_mode) {
+ ERR_THREAD_GUARD
+ if (data.accessibility_live != p_mode) {
+ data.accessibility_live = p_mode;
+ queue_accessibility_update();
+ }
+}
+
+DisplayServer::AccessibilityLiveMode Control::get_accessibility_live() const {
+ return data.accessibility_live;
+}
+
+void Control::set_accessibility_controls_nodes(const TypedArray &p_node_path) {
+ ERR_MAIN_THREAD_GUARD;
+ if (data.accessibility_controls_nodes != p_node_path) {
+ data.accessibility_controls_nodes = p_node_path;
+ queue_accessibility_update();
+ }
+}
+
+TypedArray Control::get_accessibility_controls_nodes() const {
+ return data.accessibility_controls_nodes;
+}
+
+void Control::set_accessibility_described_by_nodes(const TypedArray &p_node_path) {
+ ERR_MAIN_THREAD_GUARD;
+ if (data.accessibility_described_by_nodes != p_node_path) {
+ data.accessibility_described_by_nodes = p_node_path;
+ queue_accessibility_update();
+ }
+}
+
+TypedArray Control::get_accessibility_described_by_nodes() const {
+ return data.accessibility_described_by_nodes;
+}
+
+void Control::set_accessibility_labeled_by_nodes(const TypedArray &p_node_path) {
+ ERR_MAIN_THREAD_GUARD;
+ if (data.accessibility_labeled_by_nodes != p_node_path) {
+ data.accessibility_labeled_by_nodes = p_node_path;
+ queue_accessibility_update();
+ }
+}
+
+TypedArray Control::get_accessibility_labeled_by_nodes() const {
+ return data.accessibility_labeled_by_nodes;
+}
+
+void Control::set_accessibility_flow_to_nodes(const TypedArray &p_node_path) {
+ ERR_MAIN_THREAD_GUARD;
+ if (data.accessibility_flow_to_nodes != p_node_path) {
+ data.accessibility_flow_to_nodes = p_node_path;
+ queue_accessibility_update();
+ }
+}
+
+TypedArray Control::get_accessibility_flow_to_nodes() const {
+ return data.accessibility_flow_to_nodes;
+}
+
void Control::set_drag_preview(Control *p_control) {
ERR_MAIN_THREAD_GUARD;
ERR_FAIL_COND(!is_inside_tree());
@@ -3605,6 +3699,16 @@ void Control::_notification(int p_notification) {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
+ // Base info.
+ if (get_parent_control()) {
+ String container_info = get_parent_control()->get_accessibility_container_name(this);
+ DisplayServer::get_singleton()->accessibility_update_set_name(ae, container_info.is_empty() ? get_accessibility_name() : get_accessibility_name() + " " + container_info);
+ } else {
+ DisplayServer::get_singleton()->accessibility_update_set_name(ae, get_accessibility_name());
+ }
+ DisplayServer::get_singleton()->accessibility_update_set_description(ae, get_accessibility_description());
+ DisplayServer::get_singleton()->accessibility_update_set_live(ae, get_accessibility_live());
+
DisplayServer::get_singleton()->accessibility_update_set_transform(ae, get_transform());
DisplayServer::get_singleton()->accessibility_update_set_bounds(ae, Rect2(Vector2(), data.size_cache));
DisplayServer::get_singleton()->accessibility_update_set_tooltip(ae, data.tooltip);
@@ -3623,6 +3727,44 @@ void Control::_notification(int p_notification) {
DisplayServer::get_singleton()->accessibility_update_set_extra_info(ae, vformat(RTR("%s can not be dropped here. Use %s to cancel."), get_viewport()->gui_get_drag_description(), InputMap::get_singleton()->get_action_description("ui_cancel")));
}
}
+
+ // Related nodes.
+ for (int i = 0; i < data.accessibility_controls_nodes.size(); i++) {
+ const NodePath &np = data.accessibility_controls_nodes[i];
+ if (!np.is_empty()) {
+ Node *n = get_node(np);
+ if (n && !n->is_part_of_edited_scene()) {
+ DisplayServer::get_singleton()->accessibility_update_add_related_controls(ae, n->get_accessibility_element());
+ }
+ }
+ }
+ for (int i = 0; i < data.accessibility_described_by_nodes.size(); i++) {
+ const NodePath &np = data.accessibility_described_by_nodes[i];
+ if (!np.is_empty()) {
+ Node *n = get_node(np);
+ if (n && !n->is_part_of_edited_scene()) {
+ DisplayServer::get_singleton()->accessibility_update_add_related_described_by(ae, n->get_accessibility_element());
+ }
+ }
+ }
+ for (int i = 0; i < data.accessibility_labeled_by_nodes.size(); i++) {
+ const NodePath &np = data.accessibility_labeled_by_nodes[i];
+ if (!np.is_empty()) {
+ Node *n = get_node(np);
+ if (n && !n->is_part_of_edited_scene()) {
+ DisplayServer::get_singleton()->accessibility_update_add_related_labeled_by(ae, n->get_accessibility_element());
+ }
+ }
+ }
+ for (int i = 0; i < data.accessibility_flow_to_nodes.size(); i++) {
+ const NodePath &np = data.accessibility_flow_to_nodes[i];
+ if (!np.is_empty()) {
+ Node *n = get_node(np);
+ if (n && !n->is_part_of_edited_scene()) {
+ DisplayServer::get_singleton()->accessibility_update_add_related_flow_to(ae, n->get_accessibility_element());
+ }
+ }
+ }
} break;
case NOTIFICATION_POSTINITIALIZE: {
@@ -3962,6 +4104,22 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("accessibility_drag"), &Control::accessibility_drag);
ClassDB::bind_method(D_METHOD("accessibility_drop"), &Control::accessibility_drop);
+ ClassDB::bind_method(D_METHOD("set_accessibility_name", "name"), &Control::set_accessibility_name);
+ ClassDB::bind_method(D_METHOD("get_accessibility_name"), &Control::get_accessibility_name);
+ ClassDB::bind_method(D_METHOD("set_accessibility_description", "description"), &Control::set_accessibility_description);
+ ClassDB::bind_method(D_METHOD("get_accessibility_description"), &Control::get_accessibility_description);
+ ClassDB::bind_method(D_METHOD("set_accessibility_live", "mode"), &Control::set_accessibility_live);
+ ClassDB::bind_method(D_METHOD("get_accessibility_live"), &Control::get_accessibility_live);
+
+ ClassDB::bind_method(D_METHOD("set_accessibility_controls_nodes", "node_path"), &Control::set_accessibility_controls_nodes);
+ ClassDB::bind_method(D_METHOD("get_accessibility_controls_nodes"), &Control::get_accessibility_controls_nodes);
+ ClassDB::bind_method(D_METHOD("set_accessibility_described_by_nodes", "node_path"), &Control::set_accessibility_described_by_nodes);
+ ClassDB::bind_method(D_METHOD("get_accessibility_described_by_nodes"), &Control::get_accessibility_described_by_nodes);
+ ClassDB::bind_method(D_METHOD("set_accessibility_labeled_by_nodes", "node_path"), &Control::set_accessibility_labeled_by_nodes);
+ ClassDB::bind_method(D_METHOD("get_accessibility_labeled_by_nodes"), &Control::get_accessibility_labeled_by_nodes);
+ ClassDB::bind_method(D_METHOD("set_accessibility_flow_to_nodes", "node_path"), &Control::set_accessibility_flow_to_nodes);
+ ClassDB::bind_method(D_METHOD("get_accessibility_flow_to_nodes"), &Control::get_accessibility_flow_to_nodes);
+
ClassDB::bind_method(D_METHOD("set_mouse_filter", "filter"), &Control::set_mouse_filter);
ClassDB::bind_method(D_METHOD("get_mouse_filter"), &Control::get_mouse_filter);
ClassDB::bind_method(D_METHOD("get_mouse_filter_with_override"), &Control::get_mouse_filter_with_override);
@@ -4102,6 +4260,15 @@ void Control::_bind_methods() {
ADD_GROUP("Input", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut_context", PROPERTY_HINT_NODE_TYPE, "Node"), "set_shortcut_context", "get_shortcut_context");
+ ADD_GROUP("Accessibility", "accessibility_");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_name"), "set_accessibility_name", "get_accessibility_name");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_description"), "set_accessibility_description", "get_accessibility_description");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "accessibility_live", PROPERTY_HINT_ENUM, "Off,Polite,Assertive"), "set_accessibility_live", "get_accessibility_live");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_controls_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_controls_nodes", "get_accessibility_controls_nodes");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_described_by_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_described_by_nodes", "get_accessibility_described_by_nodes");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_labeled_by_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_labeled_by_nodes", "get_accessibility_labeled_by_nodes");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_flow_to_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_flow_to_nodes", "get_accessibility_flow_to_nodes");
+
ADD_GROUP("Theme", "theme_");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "theme_type_variation", PROPERTY_HINT_ENUM_SUGGESTION), "set_theme_type_variation", "get_theme_type_variation");
@@ -4225,6 +4392,7 @@ void Control::_bind_methods() {
GDVIRTUAL_BIND(_make_custom_tooltip, "for_text");
GDVIRTUAL_BIND(_accessibility_get_contextual_info);
+ GDVIRTUAL_BIND(_get_accessibility_container_name, "node");
GDVIRTUAL_BIND(_gui_input, "event");
}
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 3060e5bf72f..b8b47c9be9d 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -250,6 +250,17 @@ private:
ObjectID shortcut_context;
+ // Accessibility.
+
+ String accessibility_name;
+ String accessibility_description;
+ DisplayServer::AccessibilityLiveMode accessibility_live = DisplayServer::AccessibilityLiveMode::LIVE_OFF;
+
+ TypedArray accessibility_controls_nodes;
+ TypedArray accessibility_described_by_nodes;
+ TypedArray accessibility_labeled_by_nodes;
+ TypedArray accessibility_flow_to_nodes;
+
// Theming.
ThemeOwner *theme_owner = nullptr;
@@ -396,6 +407,7 @@ protected:
GDVIRTUAL1RC(Object *, _make_custom_tooltip, String)
GDVIRTUAL0RC(String, _accessibility_get_contextual_info);
+ GDVIRTUAL1RC(String, _get_accessibility_container_name, const Node *)
GDVIRTUAL1(_gui_input, Ref)
@@ -597,6 +609,31 @@ public:
void set_focus_previous(const NodePath &p_prev);
NodePath get_focus_previous() const;
+ // Accessibility.
+
+ virtual String get_accessibility_container_name(const Node *p_node) const;
+
+ void set_accessibility_name(const String &p_name);
+ String get_accessibility_name() const;
+
+ void set_accessibility_description(const String &p_description);
+ String get_accessibility_description() const;
+
+ void set_accessibility_live(DisplayServer::AccessibilityLiveMode p_mode);
+ DisplayServer::AccessibilityLiveMode get_accessibility_live() const;
+
+ void set_accessibility_controls_nodes(const TypedArray &p_node_path);
+ TypedArray get_accessibility_controls_nodes() const;
+
+ void set_accessibility_described_by_nodes(const TypedArray &p_node_path);
+ TypedArray get_accessibility_described_by_nodes() const;
+
+ void set_accessibility_labeled_by_nodes(const TypedArray &p_node_path);
+ TypedArray get_accessibility_labeled_by_nodes() const;
+
+ void set_accessibility_flow_to_nodes(const TypedArray &p_node_path);
+ TypedArray get_accessibility_flow_to_nodes() const;
+
// Rendering.
void set_default_cursor_shape(CursorShape p_shape);
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 96315d8768d..835d1107951 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -61,53 +61,7 @@ void Node::_notification(int p_notification) {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
- // Base info.
- if (data.parent) {
- String container_info = data.parent->get_accessibility_container_name(this);
- DisplayServer::get_singleton()->accessibility_update_set_name(ae, container_info.is_empty() ? get_accessibility_name() : get_accessibility_name() + " " + container_info);
- } else {
- DisplayServer::get_singleton()->accessibility_update_set_name(ae, get_accessibility_name());
- }
- DisplayServer::get_singleton()->accessibility_update_set_description(ae, get_accessibility_description());
- DisplayServer::get_singleton()->accessibility_update_set_live(ae, get_accessibility_live());
-
- // Related nodes.
- for (int i = 0; i < data.accessibility_controls_nodes.size(); i++) {
- const NodePath &np = data.accessibility_controls_nodes[i];
- if (!np.is_empty()) {
- Node *n = get_node(np);
- if (n && !n->is_part_of_edited_scene()) {
- DisplayServer::get_singleton()->accessibility_update_add_related_controls(ae, n->get_accessibility_element());
- }
- }
- }
- for (int i = 0; i < data.accessibility_described_by_nodes.size(); i++) {
- const NodePath &np = data.accessibility_described_by_nodes[i];
- if (!np.is_empty()) {
- Node *n = get_node(np);
- if (n && !n->is_part_of_edited_scene()) {
- DisplayServer::get_singleton()->accessibility_update_add_related_described_by(ae, n->get_accessibility_element());
- }
- }
- }
- for (int i = 0; i < data.accessibility_labeled_by_nodes.size(); i++) {
- const NodePath &np = data.accessibility_labeled_by_nodes[i];
- if (!np.is_empty()) {
- Node *n = get_node(np);
- if (n && !n->is_part_of_edited_scene()) {
- DisplayServer::get_singleton()->accessibility_update_add_related_labeled_by(ae, n->get_accessibility_element());
- }
- }
- }
- for (int i = 0; i < data.accessibility_flow_to_nodes.size(); i++) {
- const NodePath &np = data.accessibility_flow_to_nodes[i];
- if (!np.is_empty()) {
- Node *n = get_node(np);
- if (n && !n->is_part_of_edited_scene()) {
- DisplayServer::get_singleton()->accessibility_update_add_related_flow_to(ae, n->get_accessibility_element());
- }
- }
- }
+ DisplayServer::get_singleton()->accessibility_update_set_name(ae, get_name());
// Node children.
if (!accessibility_override_tree_hierarchy()) {
@@ -1452,91 +1406,6 @@ void Node::_propagate_translation_domain_dirty() {
}
}
-void Node::set_accessibility_name(const String &p_name) {
- ERR_THREAD_GUARD
- if (data.accessibility_name != p_name) {
- data.accessibility_name = p_name;
- queue_accessibility_update();
- update_configuration_warnings();
- }
-}
-
-String Node::get_accessibility_name() const {
- return tr(data.accessibility_name);
-}
-
-void Node::set_accessibility_description(const String &p_description) {
- ERR_THREAD_GUARD
- if (data.accessibility_description != p_description) {
- data.accessibility_description = p_description;
- queue_accessibility_update();
- }
-}
-
-String Node::get_accessibility_description() const {
- return tr(data.accessibility_description);
-}
-
-void Node::set_accessibility_live(DisplayServer::AccessibilityLiveMode p_mode) {
- ERR_THREAD_GUARD
- if (data.accessibility_live != p_mode) {
- data.accessibility_live = p_mode;
- queue_accessibility_update();
- }
-}
-
-DisplayServer::AccessibilityLiveMode Node::get_accessibility_live() const {
- return data.accessibility_live;
-}
-
-void Node::set_accessibility_controls_nodes(const TypedArray &p_node_path) {
- ERR_THREAD_GUARD
- if (data.accessibility_controls_nodes != p_node_path) {
- data.accessibility_controls_nodes = p_node_path;
- queue_accessibility_update();
- }
-}
-
-TypedArray Node::get_accessibility_controls_nodes() const {
- return data.accessibility_controls_nodes;
-}
-
-void Node::set_accessibility_described_by_nodes(const TypedArray &p_node_path) {
- ERR_THREAD_GUARD
- if (data.accessibility_described_by_nodes != p_node_path) {
- data.accessibility_described_by_nodes = p_node_path;
- queue_accessibility_update();
- }
-}
-
-TypedArray Node::get_accessibility_described_by_nodes() const {
- return data.accessibility_described_by_nodes;
-}
-
-void Node::set_accessibility_labeled_by_nodes(const TypedArray &p_node_path) {
- ERR_THREAD_GUARD
- if (data.accessibility_labeled_by_nodes != p_node_path) {
- data.accessibility_labeled_by_nodes = p_node_path;
- queue_accessibility_update();
- }
-}
-
-TypedArray Node::get_accessibility_labeled_by_nodes() const {
- return data.accessibility_labeled_by_nodes;
-}
-
-void Node::set_accessibility_flow_to_nodes(const TypedArray &p_node_path) {
- ERR_THREAD_GUARD
- if (data.accessibility_flow_to_nodes != p_node_path) {
- data.accessibility_flow_to_nodes = p_node_path;
- queue_accessibility_update();
- }
-}
-
-TypedArray Node::get_accessibility_flow_to_nodes() const {
- return data.accessibility_flow_to_nodes;
-}
-
StringName Node::get_name() const {
return data.name;
}
@@ -3806,15 +3675,6 @@ RID Node::get_focused_accessibility_element() const {
}
}
-String Node::get_accessibility_container_name(const Node *p_node) const {
- String ret;
- if (GDVIRTUAL_CALL(_get_accessibility_container_name, p_node, ret)) {
- } else if (data.parent) {
- ret = data.parent->get_accessibility_container_name(this);
- }
- return ret;
-}
-
void Node::queue_accessibility_update() {
if (is_inside_tree() && !is_part_of_edited_scene()) {
data.tree->_accessibility_notify_change(this);
@@ -3912,21 +3772,6 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_process_thread_group_order", "order"), &Node::set_process_thread_group_order);
ClassDB::bind_method(D_METHOD("get_process_thread_group_order"), &Node::get_process_thread_group_order);
- ClassDB::bind_method(D_METHOD("set_accessibility_name", "name"), &Node::set_accessibility_name);
- ClassDB::bind_method(D_METHOD("get_accessibility_name"), &Node::get_accessibility_name);
- ClassDB::bind_method(D_METHOD("set_accessibility_description", "description"), &Node::set_accessibility_description);
- ClassDB::bind_method(D_METHOD("get_accessibility_description"), &Node::get_accessibility_description);
- ClassDB::bind_method(D_METHOD("set_accessibility_live", "mode"), &Node::set_accessibility_live);
- ClassDB::bind_method(D_METHOD("get_accessibility_live"), &Node::get_accessibility_live);
- ClassDB::bind_method(D_METHOD("set_accessibility_controls_nodes", "node_path"), &Node::set_accessibility_controls_nodes);
- ClassDB::bind_method(D_METHOD("get_accessibility_controls_nodes"), &Node::get_accessibility_controls_nodes);
- ClassDB::bind_method(D_METHOD("set_accessibility_described_by_nodes", "node_path"), &Node::set_accessibility_described_by_nodes);
- ClassDB::bind_method(D_METHOD("get_accessibility_described_by_nodes"), &Node::get_accessibility_described_by_nodes);
- ClassDB::bind_method(D_METHOD("set_accessibility_labeled_by_nodes", "node_path"), &Node::set_accessibility_labeled_by_nodes);
- ClassDB::bind_method(D_METHOD("get_accessibility_labeled_by_nodes"), &Node::get_accessibility_labeled_by_nodes);
- ClassDB::bind_method(D_METHOD("set_accessibility_flow_to_nodes", "node_path"), &Node::set_accessibility_flow_to_nodes);
- ClassDB::bind_method(D_METHOD("get_accessibility_flow_to_nodes"), &Node::get_accessibility_flow_to_nodes);
-
ClassDB::bind_method(D_METHOD("queue_accessibility_update"), &Node::queue_accessibility_update);
ClassDB::bind_method(D_METHOD("get_accessibility_element"), &Node::get_accessibility_element);
@@ -4156,15 +4001,6 @@ void Node::_bind_methods() {
ADD_GROUP("Editor Description", "editor_");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "editor_description", PROPERTY_HINT_MULTILINE_TEXT), "set_editor_description", "get_editor_description");
- ADD_GROUP("Accessibility", "accessibility_");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_name"), "set_accessibility_name", "get_accessibility_name");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_description"), "set_accessibility_description", "get_accessibility_description");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "accessibility_live", PROPERTY_HINT_ENUM, "Off,Polite,Assertive"), "set_accessibility_live", "get_accessibility_live");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_controls_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_controls_nodes", "get_accessibility_controls_nodes");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_described_by_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_described_by_nodes", "get_accessibility_described_by_nodes");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_labeled_by_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_labeled_by_nodes", "get_accessibility_labeled_by_nodes");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_flow_to_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_flow_to_nodes", "get_accessibility_flow_to_nodes");
-
GDVIRTUAL_BIND(_process, "delta");
GDVIRTUAL_BIND(_physics_process, "delta");
GDVIRTUAL_BIND(_enter_tree);
@@ -4177,7 +4013,6 @@ void Node::_bind_methods() {
GDVIRTUAL_BIND(_unhandled_input, "event");
GDVIRTUAL_BIND(_unhandled_key_input, "event");
GDVIRTUAL_BIND(_get_focused_accessibility_element);
- GDVIRTUAL_BIND(_get_accessibility_container_name, "node");
}
String Node::_get_name_num_separator() {
diff --git a/scene/main/node.h b/scene/main/node.h
index e77b628a29a..d2b384b928a 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -190,14 +190,6 @@ private:
mutable RID accessibility_element;
- String accessibility_name;
- String accessibility_description;
- DisplayServer::AccessibilityLiveMode accessibility_live = DisplayServer::AccessibilityLiveMode::LIVE_OFF;
- TypedArray accessibility_controls_nodes;
- TypedArray accessibility_described_by_nodes;
- TypedArray accessibility_labeled_by_nodes;
- TypedArray accessibility_flow_to_nodes;
-
HashMap grouped;
List::Element *OW = nullptr; // Owned element.
List owned;
@@ -414,7 +406,6 @@ protected:
GDVIRTUAL1(_unhandled_key_input, Ref)
GDVIRTUAL0RC(RID, _get_focused_accessibility_element)
- GDVIRTUAL1RC(String, _get_accessibility_container_name, const Node *)
#ifndef DISABLE_DEPRECATED
void _set_name_bind_compat_76560(const String &p_name);
@@ -678,32 +669,10 @@ public:
void set_process_thread_messages(BitField p_flags);
BitField get_process_thread_messages() const;
- void set_accessibility_name(const String &p_name);
- String get_accessibility_name() const;
-
- void set_accessibility_description(const String &p_description);
- String get_accessibility_description() const;
-
- void set_accessibility_live(DisplayServer::AccessibilityLiveMode p_mode);
- DisplayServer::AccessibilityLiveMode get_accessibility_live() const;
-
- void set_accessibility_controls_nodes(const TypedArray &p_node_path);
- TypedArray get_accessibility_controls_nodes() const;
-
- void set_accessibility_described_by_nodes(const TypedArray &p_node_path);
- TypedArray get_accessibility_described_by_nodes() const;
-
- void set_accessibility_labeled_by_nodes(const TypedArray &p_node_path);
- TypedArray get_accessibility_labeled_by_nodes() const;
-
- void set_accessibility_flow_to_nodes(const TypedArray &p_node_path);
- TypedArray get_accessibility_flow_to_nodes() const;
-
void queue_accessibility_update();
virtual RID get_accessibility_element() const;
virtual RID get_focused_accessibility_element() const;
- virtual String get_accessibility_container_name(const Node *p_node) const;
virtual bool accessibility_override_tree_hierarchy() const { return false; }
virtual PackedStringArray get_accessibility_configuration_warnings() const;
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 696e09eb1f6..ca49e754fad 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -1430,7 +1430,12 @@ void Window::_notification(int p_what) {
ERR_FAIL_COND(ae.is_null());
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_WINDOW);
- DisplayServer::get_singleton()->accessibility_update_set_name(ae, tr_title);
+ if (accessibility_name.is_empty()) {
+ DisplayServer::get_singleton()->accessibility_update_set_name(ae, tr_title);
+ } else {
+ DisplayServer::get_singleton()->accessibility_update_set_name(ae, accessibility_name);
+ }
+ DisplayServer::get_singleton()->accessibility_update_set_description(ae, accessibility_description);
DisplayServer::get_singleton()->accessibility_update_set_flag(ae, DisplayServer::AccessibilityFlags::FLAG_MODAL, exclusive);
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_FOCUS, callable_mp(this, &Window::_accessibility_action_grab_focus));
DisplayServer::get_singleton()->accessibility_update_set_flag(ae, DisplayServer::AccessibilityFlags::FLAG_HIDDEN, !visible);
@@ -2212,7 +2217,33 @@ Rect2i Window::get_usable_parent_rect() const {
return parent_rect;
}
+void Window::set_accessibility_name(const String &p_name) {
+ ERR_MAIN_THREAD_GUARD;
+ if (accessibility_name != p_name) {
+ accessibility_name = p_name;
+ queue_accessibility_update();
+ update_configuration_warnings();
+ }
+}
+
+String Window::get_accessibility_name() const {
+ return tr(accessibility_name);
+}
+
+void Window::set_accessibility_description(const String &p_description) {
+ ERR_MAIN_THREAD_GUARD;
+ if (accessibility_description != p_description) {
+ accessibility_description = p_description;
+ queue_accessibility_update();
+ }
+}
+
+String Window::get_accessibility_description() const {
+ return tr(accessibility_description);
+}
+
void Window::accessibility_announcement(const String &p_announcement) {
+ ERR_MAIN_THREAD_GUARD;
announcement = p_announcement;
queue_accessibility_update();
}
@@ -3198,6 +3229,11 @@ void Window::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_window_id"), &Window::get_window_id);
+ ClassDB::bind_method(D_METHOD("set_accessibility_name", "name"), &Window::set_accessibility_name);
+ ClassDB::bind_method(D_METHOD("get_accessibility_name"), &Window::get_accessibility_name);
+ ClassDB::bind_method(D_METHOD("set_accessibility_description", "description"), &Window::set_accessibility_description);
+ ClassDB::bind_method(D_METHOD("get_accessibility_description"), &Window::get_accessibility_description);
+
ClassDB::bind_static_method("Window", D_METHOD("get_focused_window"), &Window::get_focused_window);
ClassDB::bind_method(D_METHOD("set_layout_direction", "direction"), &Window::set_layout_direction);
@@ -3274,6 +3310,10 @@ void Window::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_translate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_auto_translate", "is_auto_translating");
#endif
+ ADD_GROUP("Accessibility", "accessibility_");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_name"), "set_accessibility_name", "get_accessibility_name");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_description"), "set_accessibility_description", "get_accessibility_description");
+
ADD_GROUP("Theme", "theme_");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "theme_type_variation", PROPERTY_HINT_ENUM_SUGGESTION), "set_theme_type_variation", "get_theme_type_variation");
diff --git a/scene/main/window.h b/scene/main/window.h
index 2d41aa3420d..7f29bbd24ba 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -158,6 +158,8 @@ private:
RID accessibility_title_element;
RID accessibility_announcement_element;
String announcement;
+ String accessibility_name;
+ String accessibility_description;
void _make_window();
void _clear_window();
@@ -420,6 +422,12 @@ public:
Rect2i get_usable_parent_rect() const;
+ void set_accessibility_name(const String &p_name);
+ String get_accessibility_name() const;
+
+ void set_accessibility_description(const String &p_description);
+ String get_accessibility_description() const;
+
void accessibility_announcement(const String &p_announcement);
// Internationalization.