From: Victor Cebollada Date: Mon, 13 Mar 2017 09:08:57 +0000 (+0000) Subject: Fix for Text::Controller. X-Git-Tag: dali_1.2.32~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=162dee76321b6d0ce335fc8cd04a0bb7389b54c9 Fix for Text::Controller. * The text is scrolled to a wrong position after pasting text on top of the selected one. It happens if the pasted text has the same or more number of characters than the selected one but the width is shorter. Change-Id: I1bd5a323ec47ef6a9494ea341a4e33dee4d8f763 Signed-off-by: Victor Cebollada --- diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 55f40e9..c16cd0b 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -2276,8 +2276,9 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt void Controller::InsertText( const std::string& text, Controller::InsertType type ) { - bool removedPrevious( false ); - bool maxLengthReached( false ); + bool removedPrevious = false; + bool removedSelected = false; + bool maxLengthReached = false; DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" ) @@ -2293,9 +2294,6 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // TODO: At the moment the underline runs are only for pre-edit. mImpl->mModel->mVisualModel->mUnderlineRuns.Clear(); - // Keep the current number of characters. - const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u; - // Remove the previous IMF pre-edit. if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) ) { @@ -2309,7 +2307,8 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ else { // Remove the previous Selection. - removedPrevious = RemoveSelectedText(); + removedSelected = RemoveSelectedText(); + } Vector utf32Characters; @@ -2479,8 +2478,6 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition ); } - const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u; - if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) && mImpl->IsPlaceholderAvailable() ) { @@ -2490,13 +2487,14 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ mImpl->ClearPreEditFlag(); } else if( removedPrevious || + removedSelected || ( 0 != utf32Characters.Count() ) ) { // Queue an inserted event mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED ); mImpl->mEventData->mUpdateCursorPosition = true; - if( numberOfCharacters < currentNumberOfCharacters ) + if( removedSelected ) { mImpl->mEventData->mScrollAfterDelete = true; }