From 928cc5f80c43d7fd0e0b7bbec654d5b3b3d7b614 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 14 Jun 2021 09:05:14 +0100 Subject: [PATCH] Accessibility: Moved Component::isCurrentlyBlockedByAnotherModalComponent() check into AccessibilityHandler::getCurrentState() to determine whether handler is considered focusable and removed Component::inputAttemptWhenModal() call This prevents components from taking focus when they are blocked by another modal component by excluding them from the list of child handlers returned by AccessibilityHandler::getChildren() and fixes an issue with modal components being dismissed by handlers. --- .../juce_AccessibilityHandler.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp b/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp index e7084ebd729f..3504709dce72 100644 --- a/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp +++ b/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp @@ -74,7 +74,10 @@ AccessibilityHandler::~AccessibilityHandler() //============================================================================== AccessibleState AccessibilityHandler::getCurrentState() const { - auto state = AccessibleState().withFocusable(); + AccessibleState state; + + if (! component.isCurrentlyBlockedByAnotherModalComponent()) + state = state.withFocusable(); return hasFocus (false) ? state.withFocused() : state; } @@ -210,7 +213,7 @@ std::vector AccessibilityHandler::getChildren() const if (auto* handler = findEnclosingHandler (focusableComponent)) { - if (! isParentOf (handler)) + if (! handler->getCurrentState().isFocusable() || ! isParentOf (handler)) return; if (auto* unignored = getFirstUnignoredDescendant (handler)) @@ -283,16 +286,8 @@ void AccessibilityHandler::grabFocusInternal (bool canTryParent) { if (getCurrentState().isFocusable() && ! isIgnored()) { - const auto blockedByModal = component.isCurrentlyBlockedByAnotherModalComponent(); - - if (blockedByModal) - Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); - - if (! blockedByModal || ! component.isCurrentlyBlockedByAnotherModalComponent()) - { - takeFocus(); - return; - } + takeFocus(); + return; } if (isParentOf (currentlyFocusedHandler))