Fix for cursor position when there is no text and no place holder text.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index c70fda0..68555b7 100644 (file)
@@ -1016,7 +1016,12 @@ void Controller::CalculateTextAlignment( const Size& size )
   // Get the direction of the first character.
   const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
 
-  const Size& actualSize = mImpl->mVisualModel->GetActualSize();
+  Size actualSize = mImpl->mVisualModel->GetActualSize();
+  if( fabsf( actualSize.height ) < Math::MACHINE_EPSILON_1000 )
+  {
+    // Get the line height of the default font.
+    actualSize.height = mImpl->GetDefaultFontLineHeight();
+  }
 
   // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
   LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
@@ -1159,10 +1164,11 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
       mImpl->ChangeState( EventData::INTERRUPTED ); // State is not INACTIVE as expect to return to edit mode.
       // Avoids calling the InsertText() method which can delete selected text
     }
-    else if ( IsKey( keyEvent, Dali::DALI_KEY_MENU ) )
+    else if ( IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
+              IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
     {
       mImpl->ChangeState( EventData::INACTIVE );
-      // Menu key behaviour does not allow edit to resume like Power key
+      // Menu/Home key behaviour does not allow edit mode to resume like Power key
       // Avoids calling the InsertText() method which can delete selected text
     }
     else