From 8e626d5103f598cce309c865bfed011c9f2db565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Fri, 31 Oct 2025 18:52:18 +0200 Subject: [PATCH] Fix `grab_focus` incorrectly handling `FOCUS_ACCESSIBILITY`. --- scene/gui/control.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 8cf5c3f2937..ecfdb28d963 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2349,6 +2349,13 @@ void Control::grab_focus(bool p_hide_focus) { ERR_MAIN_THREAD_GUARD; ERR_FAIL_COND(!is_inside_tree()); + if (get_focus_mode_with_override() == FOCUS_ACCESSIBILITY) { + if (!get_tree()->is_accessibility_enabled()) { + WARN_PRINT("This control can grab focus only when screen reader is active. Use set_focus_mode() and set_focus_behavior_recursive() to allow a control to get focus. Use get_tree().is_accessibility_enabled() to check screen-reader state."); + return; + } + } + if (get_focus_mode_with_override() == FOCUS_NONE) { WARN_PRINT("This control can't grab focus. Use set_focus_mode() and set_focus_behavior_recursive() to allow a control to get focus."); return;