(TextInput) Moving selection handles when word selected does not de-select current...
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-impl.cpp
index 44c5aaf..7600969 100644 (file)
@@ -281,9 +281,9 @@ Dali::Toolkit::TextInput TextInput::New()
   TextInputPtr textInput(new TextInput());
   // Pass ownership to CustomActor via derived handle
   Dali::Toolkit::TextInput handle(*textInput);
+  handle.SetName( "TextInput");
 
   textInput->Initialize();
-
   return handle;
 }
 
@@ -1152,6 +1152,7 @@ void TextInput::CreateActiveLayer()
 {
   Actor self = Self();
   mActiveLayer = Layer::New();
+  mActiveLayer.SetName ( "ActiveLayerActor" );
 
   mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
   mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
@@ -1541,6 +1542,12 @@ void TextInput::OnLongPress(Dali::Actor actor, Dali::LongPressGesture longPress)
 {
   DALI_LOG_INFO( gLogFilter, Debug::General, "OnLongPress\n" );
 
+  // Ignore longpress if in selection mode already
+  if( mHighlightMeshActor )
+  {
+    return;
+  }
+
   if(longPress.state == Dali::Gesture::Started)
   {
     // Start edit mode on long press
@@ -2076,6 +2083,7 @@ void TextInput::SetUpTouchEvents()
 void TextInput::CreateTextViewActor()
 {
   mDisplayedTextView = Toolkit::TextView::New();
+  mDisplayedTextView.SetName( "TextView ");
   mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled );
   mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
   mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
@@ -2635,6 +2643,8 @@ void TextInput::DeleteHighlightedText( bool inheritStyle )
 
     RemoveHighlight();
 
+    EmitTextModified();
+
     if( inheritStyle )
     {
       const TextStyle oldInputStyle( mInputStyle );
@@ -3493,7 +3503,7 @@ TextInput::HighlightInfo TextInput::CalculateHighlightInfo()
           // TODO: TextView should have a table of visual rows, and each character a reference to the row
           // that it resides on. That way this enumeration is not necessary.
           Vector2 min, max;
-          if(lastIt->mIsNewLineChar)
+          if(lastIt->mIsNewParagraphChar)
           {
             // If the last character is a new line, then to get the row rect, we need to scan from the character before the new line.
             lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
@@ -3540,7 +3550,7 @@ TextInput::HighlightInfo TextInput::CalculateHighlightInfo()
       {
         // finished selection.
         Vector2 min, max;
-        if(lastIt->mIsNewLineChar)
+        if(lastIt->mIsNewParagraphChar)
         {
           lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
         }
@@ -3906,7 +3916,7 @@ bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIn
         if( fabsf( closestYdifference - currentYdifference )  < CHARACTER_THRESHOLD )
         {
           // ignore new line character.
-          if( !info.mIsNewLineChar )
+          if( !info.mIsNewParagraphChar )
           {
             matchedCharacters.push_back( info );
             numberOfMatchedCharacters++;
@@ -3920,7 +3930,7 @@ bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIn
     // and check if user is touching below previous line.
     const Toolkit::TextView::CharacterLayoutInfo& lastInfo( mTextLayoutInfo.mCharacterLayoutInfoTable[mTextLayoutInfo.mCharacterLayoutInfoTable.size() - 1] );
 
-    if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewLineChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
+    if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewParagraphChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
     {
       closestIndex = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
     }
@@ -4178,7 +4188,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP
       }
 
       Toolkit::TextView::CharacterLayoutInfo info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ];
-      if( ( visualCharacterPosition > 0 ) && info.mIsNewLineChar && !IsScrollEnabled() )
+      if( ( visualCharacterPosition > 0 ) && info.mIsNewParagraphChar && !IsScrollEnabled() )
       {
         // Prevents the cursor to exceed the boundary if the last visible character is a 'new line character' and the scroll is not enabled.
         const Vector3& size = GetControlSize();
@@ -4190,7 +4200,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP
         info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ];
       }
 
-      if(!info.mIsNewLineChar)
+      if(!info.mIsNewParagraphChar)
       {
         cursorPosition = PositionCursorAfterWordWrap( characterPosition ); // Get position of cursor/handles taking in account auto word wrap.
       }
@@ -4390,7 +4400,7 @@ std::size_t TextInput::GetRowStartFromCharacterPosition(std::size_t logicalPosit
   {
     logicalPosition--;
     std::size_t visualPosition = GetVisualPosition(logicalPosition);
-    if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewLineChar)
+    if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewParagraphChar)
     {
       logicalPosition++;
       break;
@@ -4460,7 +4470,7 @@ Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition, V
     --it;
 
     if( (it->mPosition.y < referenceLine) ||
-        (it->mIsNewLineChar) ||
+        (it->mIsNewParagraphChar) ||
         (!it->mIsVisible) )
     {
       break;
@@ -4477,7 +4487,7 @@ Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition, V
   while(it != end)
   {
     if( (it->mPosition.y > referenceLine) ||
-        (it->mIsNewLineChar) ||
+        (it->mIsNewParagraphChar) ||
         (!it->mIsVisible) )
     {
       break;
@@ -4802,6 +4812,7 @@ void TextInput::PasteText( const Text& text )
   if( update )
   {
     CursorUpdate();
+    EmitTextModified();
   }
 
   if( insertedStringLength < text.GetLength() )