From a18e1f2548ad04cca82594a8c0692a7f583290a2 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Fri, 1 Apr 2022 10:52:16 +0900 Subject: [PATCH] If USER_INTERACTION_ENABLED is disabled, it shouldn't even be focused. Change-Id: If9fd87747511bf6926bd5d7de19f951bb2b9596a --- .../dali-toolkit/utc-Dali-KeyboardFocusManager.cpp | 43 ++++++++++++++++++++++ .../devel-api/focus-manager/focus-finder.cpp | 1 + .../focus-manager/keyboard-focus-manager-impl.cpp | 10 ++--- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index f32a64f..1ca7bd4 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -2210,3 +2210,46 @@ int UtcDaliKeyboardFocusManagerChangeFocusDirectionByCustomWheelEvent(void) END_TEST; } + +int UtcDaliKeyboardFocusManagerWithUserInteractionEnabled(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliKeyboardFocusManagerWithUserInteractionEnabled"); + + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK(manager); + + // Create the first actor and add it to the stage + Actor first = Actor::New(); + first.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); + application.GetScene().Add(first); + + // Create the second actor and add it to the first actor. + Actor second = Actor::New(); + second.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); + first.Add(second); + + // Check that no actor is being focused yet. + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); + + // Check that the focus is set on the first actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); + + // Set USER_INTERACTION_ENABLED false. + second.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false); + + // Check that it will fail to set focus on the second actor as it's not userInteractionEnabled + DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == false); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); + + // Set KeyboardFocusableChildren true. + second.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true); + + // Check that the focus is set on the second actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); + + END_TEST; +} \ No newline at end of file diff --git a/dali-toolkit/devel-api/focus-manager/focus-finder.cpp b/dali-toolkit/devel-api/focus-manager/focus-finder.cpp index d338e39..2fdf285 100644 --- a/dali-toolkit/devel-api/focus-manager/focus-finder.cpp +++ b/dali-toolkit/devel-api/focus-manager/focus-finder.cpp @@ -343,6 +343,7 @@ bool IsBetterCandidate(Toolkit::Control::KeyboardFocus::Direction direction, Rec bool IsFocusable(Actor& actor) { return (actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && + actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && actor.GetProperty(Actor::Property::VISIBLE) && actor.GetProperty(Actor::Property::WORLD_COLOR).a > FULLY_TRANSPARENT); } diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index bdfdded..a64690e 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -220,7 +220,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) } } - if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) + if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) { Integration::SceneHolder currentWindow = Integration::SceneHolder::Get(actor); @@ -244,7 +244,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) } // Check whether the actor is in the stage and is keyboard focusable. - if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) + if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) { if((mIsFocusIndicatorShown == SHOW) && (mEnableFocusIndicator == ENABLE)) { @@ -552,7 +552,7 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction } } - if(nextFocusableActor && nextFocusableActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE)) + if(nextFocusableActor && nextFocusableActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && nextFocusableActor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED)) { // Whether the next focusable actor is a layout control if(IsLayoutControl(nextFocusableActor)) @@ -578,7 +578,7 @@ bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control contr Actor nextFocusableActor = GetImplementation(control).GetNextKeyboardFocusableActor(actor, direction, mFocusGroupLoopEnabled); if(nextFocusableActor) { - if(!nextFocusableActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE)) + if(!(nextFocusableActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) || nextFocusableActor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED))) { // If the actor is not focusable, ask the same layout control for the next actor to focus return DoMoveFocusWithinLayoutControl(control, nextFocusableActor, direction); @@ -597,7 +597,7 @@ bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control contr mIsWaitingKeyboardFocusChangeCommit = false; } - if(committedFocusActor && committedFocusActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE)) + if(committedFocusActor && committedFocusActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && committedFocusActor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED)) { // Whether the commited focusable actor is a layout control if(IsLayoutControl(committedFocusActor)) -- 2.7.4