Notify the IMF when backspace/cut empties the TextField 81/47481/5
authorPaul Wisbey <p.wisbey@samsung.com>
Thu, 3 Sep 2015 16:42:41 +0000 (17:42 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Fri, 4 Sep 2015 10:08:48 +0000 (11:08 +0100)
(This is the reset the virtual keyboard to upper-case)

Change-Id: Ia450bda4c58948ead2dbdd41a21e91cbe27b3524

dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h

index a0302bc..f24e69a 100644 (file)
@@ -1713,6 +1713,13 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt
     {
       mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
       mImpl->mOperationsPending = ALL_OPERATIONS;
     {
       mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
       mImpl->mOperationsPending = ALL_OPERATIONS;
+
+      // This is to reset the virtual keyboard to Upper-case
+      if( 0u == mImpl->mLogicalModel->mText.Count() )
+      {
+        NotifyImfManager();
+      }
+
       if( 0u != mImpl->mLogicalModel->mText.Count() ||
           !mImpl->IsPlaceholderAvailable() )
       {
       if( 0u != mImpl->mLogicalModel->mText.Count() ||
           !mImpl->IsPlaceholderAvailable() )
       {
@@ -1876,6 +1883,12 @@ bool Controller::BackspaceKeyEvent()
 
   if( removed )
   {
 
   if( removed )
   {
+    // This is to reset the virtual keyboard to Upper-case
+    if( 0u == mImpl->mLogicalModel->mText.Count() )
+    {
+      NotifyImfManager();
+    }
+
     if( 0u != mImpl->mLogicalModel->mText.Count() ||
         !mImpl->IsPlaceholderAvailable() )
     {
     if( 0u != mImpl->mLogicalModel->mText.Count() ||
         !mImpl->IsPlaceholderAvailable() )
     {
@@ -1891,6 +1904,22 @@ bool Controller::BackspaceKeyEvent()
   return removed;
 }
 
   return removed;
 }
 
+void Controller::NotifyImfManager()
+{
+  ImfManager imfManager = ImfManager::Get();
+
+  if( imfManager )
+  {
+    // Notifying IMF of a cursor change triggers a surrounding text request so updating it now.
+    std::string text;
+    GetText( text );
+    imfManager.SetSurroundingText( text );
+
+    imfManager.SetCursorPosition( GetLogicalCursorPosition() );
+    imfManager.NotifyCursorPosition();
+  }
+}
+
 void Controller::ShowPlaceholderText()
 {
   if( mImpl->IsPlaceholderAvailable() )
 void Controller::ShowPlaceholderText()
 {
   if( mImpl->IsPlaceholderAvailable() )
index e665ac2..3c6125d 100644 (file)
@@ -643,6 +643,11 @@ private:
   bool BackspaceKeyEvent();
 
   /**
   bool BackspaceKeyEvent();
 
   /**
+   * @brief Helper to notify IMF manager with surrounding text & cursor changes.
+   */
+  void NotifyImfManager();
+
+  /**
    * @brief Helper to clear font-specific data.
    */
   void ShowPlaceholderText();
    * @brief Helper to clear font-specific data.
    */
   void ShowPlaceholderText();