Reset Preedit variables in 'Delete All' state
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index 44a6788..9f524dc 100755 (executable)
@@ -399,6 +399,13 @@ void Controller::SetHorizontalAlignment( Text::HorizontalAlignment::Type alignme
     if( mImpl->mEventData )
     {
       mImpl->mEventData->mUpdateAlignment = true;
+
+      // Update the cursor if it's in editing mode
+      if( EventData::IsEditingState( mImpl->mEventData->mState ) )
+      {
+        mImpl->ChangeState( EventData::EDITING );
+        mImpl->mEventData->mUpdateCursorPosition = true;
+      }
     }
 
     mImpl->RequestRelayout();
@@ -3705,6 +3712,17 @@ bool Controller::RemoveText( int cursorOffset,
         }
       }
 
+      // If the number of current text and the number of characters to be deleted are same,
+      // it means all texts should be removed and all Preedit variables should be initialized.
+      if( ( currentText.Count() - numberOfCharacters == 0 ) && ( cursorIndex == 0 ) )
+      {
+        if( mImpl->mEventData )
+        {
+          mImpl->mEventData->mPreEditStartPosition = 0;
+          mImpl->mEventData->mPreEditLength = 0;
+        }
+      }
+
       // Updates the text style runs by removing characters. Runs with no characters are removed.
       mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );