Give focus and input focus at the same time 56/117456/6
authorminho.sun <minho.sun@samsung.com>
Mon, 6 Mar 2017 06:38:38 +0000 (15:38 +0900)
committerRichard Huang <r.huang@samsung.com>
Thu, 9 Mar 2017 11:35:51 +0000 (03:35 -0800)
Currently, dali has two different focus. KeyboardFocus/KeyInputFocus.
But in other framework, they works as one focus.

Two different DALi focus will be worked as one focus via making KeyboardFocusManager give KeyInputFocus to focused control.

Plus, this patch will change focus moving behavior at text controls.
To solve this problem, make text-controller determine whether this text control will lose focus or not.

Change-Id: I484b0d846de268ceb1a9a7810af360760963165b
Signed-off-by: minho.sun <minho.sun@samsung.com>
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/text/text-controller.cpp

index 28d305d..21a0349 100644 (file)
@@ -170,6 +170,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID )
     {
       // Do we need it to remember if it was previously DISABLED?
       currentlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::NORMAL );
+      currentlyFocusedControl.ClearKeyInputFocus();
     }
 
     DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__);
@@ -181,6 +182,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID )
     if( newlyFocusedControl )
     {
       newlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::FOCUSED );
+      newlyFocusedControl.SetKeyInputFocus();
     }
 
     // Push Current Focused Actor to FocusHistory
@@ -432,6 +434,7 @@ void KeyboardFocusManager::ClearFocus()
     if( currentlyFocusedControl )
     {
       currentlyFocusedControl.SetProperty( DevelControl::Property::STATE, DevelControl::NORMAL );
+      currentlyFocusedControl.ClearKeyInputFocus();
     }
   }
 
index 8500659..b9e94ec 100644 (file)
@@ -1718,8 +1718,29 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
              ( Dali::DALI_KEY_CURSOR_UP    == keyCode ) ||
              ( Dali::DALI_KEY_CURSOR_DOWN  == keyCode ) )
     {
-      mImpl->mEventData->mCheckScrollAmount = true;
+      // If don't have any text, do nothing.
+      if( !mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters )
+      {
+        return false;
+      }
 
+      uint32_t cursorPosition = mImpl->mEventData->mPrimaryCursorPosition;
+      uint32_t numberOfCharacters = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
+      uint32_t cursorLine = mImpl->mModel->mVisualModel->GetLineOfCharacter( cursorPosition );
+      uint32_t numberOfLines = mImpl->mModel->GetNumberOfLines();
+
+      // Logic to determine whether this text control will lose focus or not.
+      if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode && 0 == cursorPosition ) ||
+          ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode && numberOfCharacters == cursorPosition) ||
+          ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && cursorLine == numberOfLines -1 ) ||
+          ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && numberOfCharacters == cursorPosition && cursorLine -1 == numberOfLines -1 ) ||
+          ( Dali::DALI_KEY_CURSOR_UP == keyCode && cursorLine == 0 ) ||
+          ( Dali::DALI_KEY_CURSOR_UP == keyCode && numberOfCharacters == cursorPosition && cursorLine == 1 ) )
+      {
+        return false;
+      }
+
+      mImpl->mEventData->mCheckScrollAmount = true;
       Event event( Event::CURSOR_KEY_EVENT );
       event.p1.mInt = keyCode;
       mImpl->mEventData->mEventQueue.push_back( event );