Skip to content

Commit ba12510

Browse files
committed
Merge pull request #112251 from bruvzg/grab_ac
Fix `grab_focus` incorrectly handling `FOCUS_ACCESSIBILITY`.
2 parents 1962e7d + 8e626d5 commit ba12510

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scene/gui/control.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,13 @@ void Control::grab_focus(bool p_hide_focus) {
23492349
ERR_MAIN_THREAD_GUARD;
23502350
ERR_FAIL_COND(!is_inside_tree());
23512351

2352+
if (get_focus_mode_with_override() == FOCUS_ACCESSIBILITY) {
2353+
if (!get_tree()->is_accessibility_enabled()) {
2354+
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.");
2355+
return;
2356+
}
2357+
}
2358+
23522359
if (get_focus_mode_with_override() == FOCUS_NONE) {
23532360
WARN_PRINT("This control can't grab focus. Use set_focus_mode() and set_focus_behavior_recursive() to allow a control to get focus.");
23542361
return;

0 commit comments

Comments
 (0)