Add CursorPositionChanged Signal
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller-text-updater.cpp
index d946365..61b8c7c 100644 (file)
@@ -139,6 +139,8 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string&
     controller.ShowPlaceholderText();
   }
 
+  unsigned int oldCursorPos = (nullptr != eventData ? eventData->mPrimaryCursorPosition : 0);
+
   // Resets the cursor position.
   controller.ResetCursorPosition(lastCursorIndex);
 
@@ -156,6 +158,7 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string&
   // Do this last since it provides callbacks into application code.
   if(NULL != impl.mEditableControlInterface)
   {
+    impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, lastCursorIndex);
     impl.mEditableControlInterface->TextChanged(true);
   }
 }
@@ -172,9 +175,10 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
     return;
   }
 
-  bool removedPrevious  = false;
-  bool removedSelected  = false;
-  bool maxLengthReached = false;
+  bool         removedPrevious  = false;
+  bool         removedSelected  = false;
+  bool         maxLengthReached = false;
+  unsigned int oldCursorPos     = eventData->mPrimaryCursorPosition;
 
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n", &controller, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"), eventData->mPrimaryCursorPosition, eventData->mPreEditFlag, eventData->mPreEditStartPosition, eventData->mPreEditLength);
 
@@ -418,6 +422,11 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
     }
   }
 
+  if(nullptr != impl.mEditableControlInterface)
+  {
+    impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, eventData->mPrimaryCursorPosition);
+  }
+
   if(maxLengthReached)
   {
     DALI_LOG_INFO(gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", logicalModel->mText.Count());
@@ -561,6 +570,11 @@ bool Controller::TextUpdater::RemoveText(
         RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
       }
 
+      if(nullptr != impl.mEditableControlInterface)
+      {
+        impl.mEditableControlInterface->CursorPositionChanged(previousCursorIndex, cursorIndex);
+      }
+
       // Cursor position retreat
       previousCursorIndex = cursorIndex;