(TextInput) Double tap on whitespace gives selection options not cut or copy 62/27962/1
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Fri, 19 Sep 2014 10:49:40 +0000 (11:49 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Tue, 23 Sep 2014 13:58:12 +0000 (14:58 +0100)
Change-Id: Idaf77f6e19e055f8192cabe36068897200ea0311
Signed-off-by: Agnelo Vaz <agnelo.vaz@samsung.com>
base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp
base/dali-toolkit/internal/controls/text-input/text-input-impl.h
base/dali-toolkit/internal/controls/text-view/text-processor.cpp

index e01c471..d7eed95 100644 (file)
@@ -1401,10 +1401,20 @@ void TextInput::OnDoubleTap(Dali::Actor actor, Dali::TapGesture tap)
        imfManager.NotifyCursorPosition();
      }
 
        imfManager.NotifyCursorPosition();
      }
 
-     SelectText( start, end );
+     if ( !mStyledText.at(end-1).mText[0].IsWhiteSpace() )
+     {
+       SelectText( start, end );
+       ShowPopupCutCopyPaste();
+     }
+     else
+     {
+       RemoveHighlight( false ); // Remove highlight but do not auto hide popup
+       HidePopup( false ); // Hide popup with setting to do auto show.
+       SetUpPopupSelection( false ); // Set to false so if nearest word is whitespace it will not show cut button.
+       ShowPopup();
+     }
    }
    }
-   // if no text but clipboard has content then show paste option
-   if ( ( mClipboard && mClipboard.NumberOfItems() ) || !mStyledText.empty() )
+   else if ( mClipboard && mClipboard.NumberOfItems() )
    {
      ShowPopupCutCopyPaste();
    }
    {
      ShowPopupCutCopyPaste();
    }
@@ -3851,7 +3861,7 @@ void TextInput::ShowPopupCutCopyPaste()
   ShowPopup();
 }
 
   ShowPopup();
 }
 
-void TextInput::SetUpPopupSelection()
+void TextInput::SetUpPopupSelection( bool treatWhiteSpaceAsAnyOtherCharacter )
 {
   ClearPopup();
   mPopupPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed
 {
   ClearPopup();
   mPopupPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed
@@ -3860,7 +3870,7 @@ void TextInput::SetUpPopupSelection()
   {
     mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelectAll, true );
     mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelect, true );
   {
     mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelectAll, true );
     mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelect, true );
-    mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCut, true );
+    mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCut, treatWhiteSpaceAsAnyOtherCharacter );
   }
   // if clipboard has valid contents then offer paste option
   if( mClipboard && mClipboard.NumberOfItems() )
   }
   // if clipboard has valid contents then offer paste option
   if( mClipboard && mClipboard.NumberOfItems() )
@@ -4687,7 +4697,7 @@ void TextInput::KeyboardStatusChanged(bool keyboardShown)
 }
 
 // Removes highlight and resumes edit mode state
 }
 
 // Removes highlight and resumes edit mode state
-void TextInput::RemoveHighlight()
+void TextInput::RemoveHighlight( bool hidePopup )
 {
   DALI_LOG_INFO(gLogFilter, Debug::General, "RemoveHighlight\n");
 
 {
   DALI_LOG_INFO(gLogFilter, Debug::General, "RemoveHighlight\n");
 
@@ -4717,7 +4727,10 @@ void TextInput::RemoveHighlight()
     // NOTE: We cannot dereference mHighlightMesh, due
     // to a bug in how the scene-graph MeshRenderer uses the Mesh data incorrectly.
 
     // NOTE: We cannot dereference mHighlightMesh, due
     // to a bug in how the scene-graph MeshRenderer uses the Mesh data incorrectly.
 
-    HidePopup();
+    if ( hidePopup )
+    {
+      HidePopup();
+    }
   }
 
   mSelectionHandleOnePosition = 0;
   }
 
   mSelectionHandleOnePosition = 0;
index dfbb2c5..556daca 100644 (file)
@@ -1084,8 +1084,10 @@ public:  // Public to allow internal testing.
 
   /**
    * Setup the selection popup and clipboard if relevant so the correct options are shown when ShowPopup is called.
 
   /**
    * Setup the selection popup and clipboard if relevant so the correct options are shown when ShowPopup is called.
+   * @param[in] treatWhiteSpaceAsAnyOtherCharacter If whitespace should not be selected in the same manner as other characters set
+   *  this to false. default is true.
    */
    */
-  void SetUpPopupSelection();
+  void SetUpPopupSelection( bool treatWhiteSpaceAsAnyOtherCharacter = true );
 
   /**
    * Return the logical index containing the character position closest to the source.
 
   /**
    * Return the logical index containing the character position closest to the source.
@@ -1218,8 +1220,9 @@ public:  // Public to allow internal testing.
 
   /**
    * Hide highlight shown between selection handles.
 
   /**
    * Hide highlight shown between selection handles.
+   * @param[in] hidePopup flag to hide the popup too, default is to hide popup.
    */
    */
-  void RemoveHighlight();
+  void RemoveHighlight( bool hidePopup = true );
 
   /**
    * Highlights text that has been selected
 
   /**
    * Highlights text that has been selected
index b41b841..99b7b59 100644 (file)
@@ -175,6 +175,11 @@ void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offse
     {
       j++;
     }
     {
       j++;
     }
+
+    while(i > 0 && IsWhiteSpace(text, i-1))
+    {
+      i--;
+    }
   }
 
   start = i;
   }
 
   start = i;