From: Seoyeon Kim Date: Fri, 28 Apr 2017 07:37:03 +0000 (+0900) Subject: Fix RemoveText code in text-controller.cpp X-Git-Tag: dali_1.2.41~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d8f1b171d295a8de12725ca4df862589f9419db;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Fix RemoveText code in text-controller.cpp - 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 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index c0a7076..8d73622 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -194,6 +194,18 @@ int UtcDaliTextControllerImfEvent(void) 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 ); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 7545481..d02f9aa 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -2681,12 +2681,12 @@ bool Controller::RemoveText( int cursorOffset, Vector& currentText = mImpl->mModel->mLogicalModel->mText; CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition; - CharacterIndex cursorIndex = oldCursorIndex; + CharacterIndex cursorIndex = 0; // 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() )