From: joogab.yun Date: Mon, 28 Mar 2022 10:13:28 +0000 (+0900) Subject: Changed to not always clearFocus when a touch occurs. X-Git-Tag: dali_2.1.17~11^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=c8fc0c045a0d0d7103ec586f764f1c45b260b984 Changed to not always clearFocus when a touch occurs. Do ClearFocus when focus movement is possible. Otherwise, only the FocusIndicator is cleared. Change-Id: I7e482e78e0af590304d066549a554d4fa39d3613 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index 7b08e1a..f32a64f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -1936,8 +1936,8 @@ int UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActorInTouchMode(void) application.SendNotification(); application.Render(); - // Check that the focus is successfully to clear - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); + // Since no focus has been moved, the current focus actor is the same. + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); // Make the second actor focusableInTouchMode second.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true); 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 d492a29..bdfdded 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -679,14 +679,10 @@ void KeyboardFocusManager::DoKeyboardEnter(Actor actor) void KeyboardFocusManager::ClearFocus() { + ClearFocusIndicator(); Actor actor = GetCurrentFocusActor(); if(actor) { - if(mFocusIndicatorActor) - { - actor.Remove(mFocusIndicatorActor); - } - // Send notification for the change of focus actor if(!mFocusChangedSignal.Empty()) { @@ -700,8 +696,19 @@ void KeyboardFocusManager::ClearFocus() currentlyFocusedControl.ClearKeyInputFocus(); } } - mCurrentFocusActor.Reset(); +} + +void KeyboardFocusManager::ClearFocusIndicator() +{ + Actor actor = GetCurrentFocusActor(); + if(actor) + { + if(mFocusIndicatorActor) + { + actor.Remove(mFocusIndicatorActor); + } + } mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE; } @@ -1003,18 +1010,30 @@ void KeyboardFocusManager::OnTouch(const TouchEvent& touch) // We only do this on a Down event, otherwise the clear action may override a manually focused actor. if(((touch.GetPointCount() < 1) || (touch.GetState(0) == PointState::DOWN))) { - // If mClearFocusOnTouch is false, do not clear the focus even if user touch the screen. - if(mClearFocusOnTouch) + // If you touch the currently focused actor again, you don't need to do SetCurrentFocusActor again. + Actor hitActor = touch.GetHitActor(0); + if(hitActor && hitActor == GetCurrentFocusActor()) { - ClearFocus(); + return; } - // If KEYBOARD_FOCUSABLE and TOUCH_FOCUSABLE is true, set focus actor - Actor hitActor = touch.GetHitActor(0); if(hitActor && hitActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && hitActor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE)) { + // If mClearFocusOnTouch is false, do not clear the focus + if(mClearFocusOnTouch) + { + ClearFocus(); + } SetCurrentFocusActor(hitActor); } + else + { + // If mClearFocusOnTouch is false, do not clear the focus indicator even if user touch the screen. + if(mClearFocusOnTouch) + { + ClearFocusIndicator(); + } + } } } diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h index 3b09623..ae06097 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h @@ -323,6 +323,11 @@ private: */ bool EmitCustomWheelSignals(Actor actor, const WheelEvent& event); + /** + * Clear the focus indicator actor. + */ + void ClearFocusIndicator(); + private: // Undefined KeyboardFocusManager(const KeyboardFocusManager&);