Notify the IMF when backspace/cut empties the TextField
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index 822a62f..f24e69a 100644 (file)
@@ -234,6 +234,7 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, boo
   }
 
   mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
+  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s userDefined: %s\n", defaultFontFamily.c_str(), userDefined ? "true":"false" );
   mImpl->mUserDefinedFontFamily = userDefined;
 
   // Clear the font-specific data
@@ -1712,6 +1713,13 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt
     {
       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() )
       {
@@ -1875,6 +1883,12 @@ bool Controller::BackspaceKeyEvent()
 
   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() )
     {
@@ -1890,6 +1904,22 @@ bool Controller::BackspaceKeyEvent()
   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() )