From 8d8f1b171d295a8de12725ca4df862589f9419db Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Fri, 28 Apr 2017 16:37:03 +0900 Subject: [PATCH] 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 --- .../src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp | 12 ++++++++++++ dali-toolkit/internal/text/text-controller.cpp | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) 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() ) -- 2.7.4