Fix RemoveText code in text-controller.cpp 61/127661/7
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 28 Apr 2017 07:37:03 +0000 (16:37 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 18 May 2017 13:02:17 +0000 (22:02 +0900)
- There is 'Delete All' key of TV remote control
- If the user wants to 'Delete All' texts focused, then the primary cursor
  has to be situated in the head of texts.

Change-Id: Id56e8dd1ba63130993ffc8a4332b5dd8a9e8c2de
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
dali-toolkit/internal/text/text-controller.cpp

index c0a7076..8d73622 100644 (file)
@@ -194,6 +194,18 @@ int UtcDaliTextControllerImfEvent(void)
   controller->GetText( text );
   DALI_TEST_CHECK( text.empty() );
 
   controller->GetText( text );
   DALI_TEST_CHECK( text.empty() );
 
+  imfEvent = ImfManager::ImfEventData( ImfManager::COMMIT, "Hello ", 0, 6 );
+  controller->OnImfEvent( imfManager, imfEvent );
+  controller->GetNaturalSize();
+
+  // Check 'Delete All' key which means the input panel send a big range
+  imfEvent = ImfManager::ImfEventData( ImfManager::DELETESURROUNDING, "", -100, 100 );
+  controller->OnImfEvent( imfManager, imfEvent );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "", text, TEST_LOCATION );
+
   // Send COMMIT event.
   imfEvent = ImfManager::ImfEventData( ImfManager::COMMIT, "Hello ", 0, 6 );
   controller->OnImfEvent( imfManager, imfEvent );
   // Send COMMIT event.
   imfEvent = ImfManager::ImfEventData( ImfManager::COMMIT, "Hello ", 0, 6 );
   controller->OnImfEvent( imfManager, imfEvent );
index 7545481..d02f9aa 100644 (file)
@@ -2681,12 +2681,12 @@ bool Controller::RemoveText( int cursorOffset,
     Vector<Character>& currentText = mImpl->mModel->mLogicalModel->mText;
     CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
 
     Vector<Character>& currentText = mImpl->mModel->mLogicalModel->mText;
     CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
 
-    CharacterIndex cursorIndex = oldCursorIndex;
+    CharacterIndex cursorIndex = 0;
 
     // Validate the cursor position & number of characters
 
     // Validate the cursor position & number of characters
-    if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex )
+    if( ( static_cast< int >( mImpl->mEventData->mPrimaryCursorPosition ) + cursorOffset ) >= 0 )
     {
     {
-      cursorIndex = oldCursorIndex + cursorOffset;
+      cursorIndex = mImpl->mEventData->mPrimaryCursorPosition + cursorOffset;
     }
 
     if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
     }
 
     if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )