From 6b708ec31364694c917a69faf8ffd6350f9e62fb Mon Sep 17 00:00:00 2001 From: "minho.sun" Date: Tue, 12 Sep 2017 15:22:22 +0900 Subject: [PATCH] Do not clear keyboard focus on touch when alwaysShowFocus is true. Do not clear keyboard focus on touch when alwaysShowFocus is ture. TV app developer can use this feature to keep showing focus to app user. Change-Id: I00c52244047172cb9d52310d3767a0eae3b67ef0 Signed-off-by: minho.sun --- .../internal/focus-manager/keyboard-focus-manager-impl.cpp | 12 +++++++++++- .../internal/focus-manager/keyboard-focus-manager-impl.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 c3ebe62..3f398c5 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -122,6 +122,7 @@ KeyboardFocusManager::KeyboardFocusManager() mIsFocusIndicatorEnabled( -1 ), mFocusGroupLoopEnabled( false ), mIsWaitingKeyboardFocusChangeCommit( false ), + mClearFocusOnTouch( true ), mFocusHistory(), mSlotDelegate( this ), mCustomAlgorithmInterface(NULL) @@ -142,6 +143,7 @@ void KeyboardFocusManager::GetConfigurationFromStyleManger() { Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager ); mIsFocusIndicatorEnabled = static_cast(config["alwaysShowFocus"].Get()); + mClearFocusOnTouch = mIsFocusIndicatorEnabled ? false : true; } } @@ -863,9 +865,17 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) void KeyboardFocusManager::OnTouch(const TouchData& touch) { + // if mIsFocusIndicatorEnabled is -1, it means Configuration is not loaded. + // Try to load configuration. + if( mIsFocusIndicatorEnabled == -1 ) + { + GetConfigurationFromStyleManger(); + } + // Clear the focus when user touch the screen. // 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( (( touch.GetPointCount() < 1 ) || ( touch.GetState( 0 ) == PointState::DOWN )) && mClearFocusOnTouch ) { ClearFocus(); } 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 049ce1f..32a0390 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h @@ -265,6 +265,8 @@ private: bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet. + bool mClearFocusOnTouch:1; ///< Whether clear focus on touch. + FocusStack mFocusHistory; ///< Stack to contain pre-focused actor's BaseObject* SlotDelegate< KeyboardFocusManager > mSlotDelegate; -- 2.7.4