Text selection refactoring 77/244477/13
authorali198724 <ali198724@gmail.com>
Fri, 18 Sep 2020 16:16:53 +0000 (19:16 +0300)
committerjoogab yun <joogab.yun@samsung.com>
Mon, 12 Oct 2020 09:47:44 +0000 (09:47 +0000)
1- Move all of selection text functionality into SelectableControlInterface
2- Support (SelectWholeText, SelectNone, GetSelectedText) in TextEditor

Change-Id: I4da66433a09e99be09f6bd027761c3ea49cfc9f5

14 files changed:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp [new file with mode: 0755]
automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.cpp
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-selectable-control-interface.h

index 851ca00..4c31f29 100755 (executable)
@@ -28,6 +28,7 @@ SET(TC_SOURCES
  utc-Dali-Text-Typesetter.cpp
  utc-Dali-Text-ViewModel.cpp
  utc-Dali-TextField-internal.cpp
+ utc-Dali-TextEditor-internal.cpp
  utc-Dali-TextSelectionPopup-internal.cpp
  utc-Dali-TextureManager.cpp
  utc-Dali-Visuals-internal.cpp
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp
new file mode 100755 (executable)
index 0000000..9445be6
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/text-controller-impl.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+int UtcDaliTextEditorSelectText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliTextEditorSelectText" );
+
+  // Create a text editor
+  TextEditor textEditor = TextEditor::New();
+  textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
+  textEditor.SetProperty( TextEditor::Property::TEXT, "Hello World" );
+
+  // Add the text editor to the stage
+  application.GetScene().Add( textEditor );
+
+  application.SendNotification();
+  application.Render();
+
+  Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor );
+
+  application.SendNotification();
+  application.Render();
+
+  // Highlight the whole text
+  textEditorImpl.SelectWholeText();
+
+  application.SendNotification();
+  application.Render();
+
+  std::string selectedText = textEditorImpl.GetSelectedText();
+  DALI_TEST_CHECK( selectedText == "Hello World" );
+
+  // Select None
+  textEditorImpl.SelectNone();
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditorImpl.GetSelectedText();
+  DALI_TEST_CHECK( selectedText == "" );
+
+  END_TEST;
+}
index a098f73..37d54e1 100755 (executable)
@@ -112,3 +112,43 @@ int UtcDaliTextFieldMultipleBackgroundText(void)
 
   END_TEST;
 }
+
+int UtcDaliTextFieldSelectText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliTextFieldSelectText" );
+
+  // Create a text field
+  TextField textField = TextField::New();
+  textField.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
+  textField.SetProperty( TextField::Property::TEXT, "Hello World" );
+
+  // Add the text field to the stage
+  application.GetScene().Add( textField );
+
+  application.SendNotification();
+  application.Render();
+
+  Toolkit::Internal::TextField& textFieldImpl = GetImpl( textField );
+
+  application.SendNotification();
+  application.Render();
+
+  // Highlight the whole text
+  textFieldImpl.SelectWholeText();
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( textFieldImpl.GetSelectedText() == "Hello World" );
+
+  // Select None
+  textFieldImpl.SelectNone();
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( textFieldImpl.GetSelectedText() == "" );
+
+  END_TEST;
+}
index 574cbf9..7a3ce4c 100644 (file)
@@ -2861,6 +2861,107 @@ int utcDaliTextEditorMaxCharactersReached(void)
   END_TEST;
 }
 
+int UtcDaliTextEditorSelectWholeText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextEditorSelectWholeText ");
+
+  TextEditor textEditor = TextEditor::New();
+
+  application.GetScene().Add( textEditor );
+
+  textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
+
+  DevelTextEditor::SelectWholeText( textEditor );
+
+  application.SendNotification();
+  application.Render();
+
+  // Nothing should have been selected. The number of children is still 1
+  DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
+
+  textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
+
+  application.SendNotification();
+  application.Render();
+
+  DevelTextEditor::SelectWholeText( textEditor );
+
+  application.SendNotification();
+  application.Render();
+
+  // Should be 2 children, the stencil and the layer
+  DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
+
+  // The offscreen root actor should have two actors: the renderer and the highlight actor.
+  Actor stencil = textEditor.GetChildAt( 0u );
+
+  // The highlight actor is drawn first, so is the first actor in the list
+  Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
+  DALI_TEST_CHECK( highlight );
+
+  END_TEST;
+}
+
+int UtcDaliTextEditorSelectNone(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextEditorSelectWholeText ");
+
+  TextEditor textEditor = TextEditor::New();
+
+  application.GetScene().Add( textEditor );
+
+  textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
+
+  application.SendNotification();
+  application.Render();
+
+  // Nothing is selected
+  std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+  DevelTextEditor::SelectWholeText( textEditor );
+
+  application.SendNotification();
+  application.Render();
+
+  // whole text is selected
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
+
+  DevelTextEditor::SelectNone( textEditor );
+
+  application.SendNotification();
+  application.Render();
+
+  // Nothing is selected
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliTextEditorSelectRange(void)
 {
   ToolkitTestApplication application;
@@ -2882,6 +2983,10 @@ int UtcDaliTextEditorSelectRange(void)
   textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
   textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
 
+  // Hello is selected
+  std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
   DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
 
index 5858d99..adcff4c 100644 (file)
@@ -35,6 +35,16 @@ MaxLengthReachedSignalType& MaxLengthReachedSignal(TextEditor textEditor)
   return GetImpl(textEditor).MaxLengthReachedSignal();
 }
 
+void SelectWholeText(TextEditor textEditor)
+{
+  GetImpl(textEditor).SelectWholeText();
+}
+
+void SelectNone(TextEditor textEditor)
+{
+  GetImpl(textEditor).SelectNone();
+}
+
 } // namespace DevelTextEditor
 
 } // namespace Toolkit
index 619f91a..0db66e5 100644 (file)
@@ -84,41 +84,41 @@ enum Type
   LINE_WRAP_MODE                       = Dali::Toolkit::TextEditor::Property::LINE_WRAP_MODE,
 
   /**
-       * @brief The text to display when the TextEditor is empty and inactive.
-       * @details Name "placeholderText", type Property::STRING.
-       */
+   * @brief The text to display when the TextEditor is empty and inactive.
+   * @details Name "placeholderText", type Property::STRING.
+   */
   PLACEHOLDER_TEXT,
 
   /**
-       * @brief The placeholder-text color.
-       * @details Name "placeholderTextColor", type Property::VECTOR4.
-       */
+   * @brief The placeholder-text color.
+   * @details Name "placeholderTextColor", type Property::VECTOR4.
+   */
   PLACEHOLDER_TEXT_COLOR,
 
   /**
-       * @brief Enables Text selection using Shift key.
-       * @details Name "enableShiftSelection", type Property::BOOLEAN.
-       */
+   * @brief Enables Text selection using Shift key.
+   * @details Name "enableShiftSelection", type Property::BOOLEAN.
+   */
   ENABLE_SHIFT_SELECTION,
 
   /**
-       * @brief Enables the grab handles for text selection.
-       * @details Name "enableGrabHandle", type Property::BOOLEAN.
-       * @note The default value is true, which means the grab handles are enabled by default.
-       */
+   * @brief Enables the grab handles for text selection.
+   * @details Name "enableGrabHandle", type Property::BOOLEAN.
+   * @note The default value is true, which means the grab handles are enabled by default.
+   */
   ENABLE_GRAB_HANDLE,
 
   /**
-       * @brief Modifies the default text alignment to match the direction of the system language.
-       * @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
-       * @note The default value is false
-       */
+   * @brief Modifies the default text alignment to match the direction of the system language.
+   * @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
+   * @note The default value is false
+   */
   MATCH_SYSTEM_LANGUAGE_DIRECTION,
 
   /**
-       * @brief The type or rendering e.g. bitmap-based.
-       * @details Name "renderingBackend", type Property::INTEGER.
-       */
+   * @brief The type or rendering e.g. bitmap-based.
+   * @details Name "renderingBackend", type Property::INTEGER.
+   */
   RENDERING_BACKEND,
 
   /**
@@ -141,9 +141,16 @@ enum Type
 
   /**
    * @brief The Editable state of control.
-   * @details Name "editable", type Property::BOOL.
+   * @details Name "enableEditing", type Property::BOOLEAN.
    */
   ENABLE_EDITING,
+
+  /**
+   * @brief The selected text in UTF-8 format.
+   * @details Name "selectedText", type Property::STRING.
+   * @note This property is read-only.
+   */
+  SELECTED_TEXT,
 };
 
 } // namespace Property
@@ -173,6 +180,20 @@ using MaxLengthReachedSignalType = Signal<void(TextEditor)>;
  */
 DALI_TOOLKIT_API MaxLengthReachedSignalType& MaxLengthReachedSignal(TextEditor textEditor);
 
+/**
+ * @brief Select the whole text of TextEditor.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ */
+DALI_TOOLKIT_API void SelectWholeText(TextEditor textEditor);
+
+/**
+ * @brief Unselect the whole text of TextEditor.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ */
+DALI_TOOLKIT_API void SelectNone(TextEditor textEditor);
+
 } // namespace DevelTextEditor
 
 } // namespace Toolkit
index 824d83c..cec1709 100644 (file)
@@ -84,51 +84,51 @@ enum
   ELLIPSIS                             = Dali::Toolkit::TextField::Property::ELLIPSIS,
 
   /**
-       * @brief Enables Text selection using Shift key.
-       * @details Name "enableShiftSelection", type Property::BOOLEAN.
-       */
+   * @brief Enables Text selection using Shift key.
+   * @details Name "enableShiftSelection", type Property::BOOLEAN.
+   */
   ENABLE_SHIFT_SELECTION = ELLIPSIS + 1,
 
   /**
-       * @brief Enables the grab handles for text selection.
-       * @details Name "enableGrabHandle", type Property::BOOLEAN.
-       * @note The default value is true, which means the grab handles are enabled by default.
-       */
+   * @brief Enables the grab handles for text selection.
+   * @details Name "enableGrabHandle", type Property::BOOLEAN.
+   * @note The default value is true, which means the grab handles are enabled by default.
+   */
   ENABLE_GRAB_HANDLE = ELLIPSIS + 2,
 
   /**
-       * @brief Modifies the default text alignment to match the direction of the system language.
-       * @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
-       * @note The default value is false
-       */
+   * @brief Modifies the default text alignment to match the direction of the system language.
+   * @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
+   * @note The default value is false
+   */
   MATCH_SYSTEM_LANGUAGE_DIRECTION = ELLIPSIS + 3,
 
   /**
-        * @brief Enables the grab handle popup for text selection.
-        * @details Name "enableGrabHandlePopup", type Property::BOOLEAN.
-        * @note The default value is true, which means the grab handle popup is enabled by default.
-        */
+   * @brief Enables the grab handle popup for text selection.
+   * @details Name "enableGrabHandlePopup", type Property::BOOLEAN.
+   * @note The default value is true, which means the grab handle popup is enabled by default.
+   */
   ENABLE_GRAB_HANDLE_POPUP = ELLIPSIS + 4,
 
   /**
-       * @brief The default text background parameters.
-       * @details Name "textBackground", type Property::VECTOR4.
-       * @note Use "textBackground" as property name to avoid conflict with Control's "background" property.
-       * @note The default value is Color::TRANSPARENT.
-       */
+   * @brief The default text background parameters.
+   * @details Name "textBackground", type Property::VECTOR4.
+   * @note Use "textBackground" as property name to avoid conflict with Control's "background" property.
+   * @note The default value is Color::TRANSPARENT.
+   */
   BACKGROUND = ELLIPSIS + 5,
 
   /**
-       * @brief The selected text in UTF-8 format.
-       * @details Name "selectedText", type Property::STRING.
-       * @note This property is read-only.
-       */
+   * @brief The selected text in UTF-8 format.
+   * @details Name "selectedText", type Property::STRING.
+   * @note This property is read-only.
+   */
   SELECTED_TEXT = ELLIPSIS + 6,
 
   /**
-       * @brief The type or rendering e.g. bitmap-based.
-       * @details Name "renderingBackend", type Property::INTEGER.
-       */
+   * @brief The type or rendering e.g. bitmap-based.
+   * @details Name "renderingBackend", type Property::INTEGER.
+   */
   RENDERING_BACKEND = ELLIPSIS + 7,
 
   /**
@@ -145,7 +145,7 @@ enum
 
   /**
    * @brief The Editable state of control.
-   * @details Name "editable", type Property::BOOL.
+   * @details Name "enableEditing", type Property::BOOLEAN.
    */
   ENABLE_EDITING,
 
index 4224df2..60db674 100644 (file)
@@ -143,6 +143,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "maxLength",
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectedTextStart",              INTEGER,   SELECTED_TEXT_START                  )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectedTextEnd",                INTEGER,   SELECTED_TEXT_END                    )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableEditing",                  BOOLEAN,   ENABLE_EDITING                       )
+DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "selectedText",         STRING,    SELECTED_TEXT                        )
 
 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged",        SIGNAL_TEXT_CHANGED )
 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged",  SIGNAL_INPUT_STYLE_CHANGED )
@@ -701,22 +702,16 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       }
       case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
       {
-        if( impl.mController )
-        {
-          uint32_t start = static_cast<uint32_t>(value.Get< int >());
-          DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
-          impl.SetTextSelectionRange( &start, nullptr );
-        }
+        uint32_t start = static_cast<uint32_t>(value.Get< int >());
+        DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
+        impl.SetTextSelectionRange( &start, nullptr );
         break;
       }
       case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
       {
-        if( impl.mController )
-        {
-          uint32_t end = static_cast<uint32_t>(value.Get< int >());
-          DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
-          impl.SetTextSelectionRange( nullptr, &end );
-        }
+        uint32_t end = static_cast<uint32_t>(value.Get< int >());
+        DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
+        impl.SetTextSelectionRange( nullptr, &end );
         break;
       }
       case Toolkit::DevelTextEditor::Property::ENABLE_EDITING:
@@ -1040,6 +1035,11 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
         value = impl.mController->GetMaximumNumberOfCharacters();
         break;
       }
+      case Toolkit::DevelTextEditor::Property::SELECTED_TEXT:
+      {
+        value = impl.mController->GetSelectedText( );
+        break;
+      }
       case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
       {
         Uint32Pair range = impl.GetTextSelectionRange();
@@ -1063,6 +1063,33 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
   return value;
 }
 
+void TextEditor::SelectWholeText()
+{
+  if( mController && mController->IsShowingRealText() )
+  {
+    mController->SelectWholeText();
+    SetKeyInputFocus();
+  }
+}
+
+void TextEditor::SelectNone()
+{
+  if( mController && mController->IsShowingRealText() )
+  {
+    mController->SelectNone();
+  }
+}
+
+string TextEditor::GetSelectedText() const
+{
+  string selectedText = "";
+  if( mController && mController->IsShowingRealText() )
+  {
+    selectedText = mController->GetSelectedText( );
+  }
+  return selectedText;
+}
+
 InputMethodContext TextEditor::GetInputMethodContext()
 {
   return mInputMethodContext;
index f89520e..2aca941 100755 (executable)
@@ -216,6 +216,21 @@ public:
   Uint32Pair GetTextSelectionRange() const override;
 
   /**
+   * @copydoc Text::SelectableControlInterface::SelectWholeText()
+   */
+  void SelectWholeText() override;
+
+  /**
+   * @copydoc Text::SelectableControlInterface::SelectNone()
+   */
+  void SelectNone() override;
+
+  /**
+   * @copydoc Text::SelectableControlInterface::GetSelectedText()
+   */
+  string GetSelectedText() const override;
+
+  /**
    * @copydoc Text::EditableControlInterface::IsEditable()
    */
   bool IsEditable() const override;
index c038d08..a85a342 100644 (file)
@@ -714,22 +714,16 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       }
       case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
       {
-        if( impl.mController )
-        {
-          uint32_t start = static_cast<uint32_t>(value.Get< int >());
-          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
-          impl.SetTextSelectionRange( &start, nullptr );
-        }
+        uint32_t start = static_cast<uint32_t>(value.Get< int >());
+        DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
+        impl.SetTextSelectionRange( &start, nullptr );
         break;
       }
       case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
       {
-        if( impl.mController )
-        {
-          uint32_t end = static_cast<uint32_t>(value.Get< int >());
-          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
-          impl.SetTextSelectionRange( nullptr, &end );
-        }
+        uint32_t end = static_cast<uint32_t>(value.Get< int >());
+        DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
+        impl.SetTextSelectionRange( nullptr, &end );
         break;
       }
       case Toolkit::DevelTextField::Property::ENABLE_EDITING:
@@ -1089,7 +1083,7 @@ void TextField::SelectWholeText()
 {
   if( mController && mController->IsShowingRealText() )
   {
-    mController->SelectEvent( 0.f, 0.f, SelectionType::ALL );
+    mController->SelectWholeText();
     SetKeyInputFocus();
   }
 }
@@ -1098,9 +1092,18 @@ void TextField::SelectNone()
 {
   if( mController && mController->IsShowingRealText() )
   {
-    mController->SelectEvent( 0.f, 0.f, SelectionType::NONE );
-    SetKeyInputFocus();
+    mController->SelectNone();
+  }
+}
+
+string TextField::GetSelectedText() const
+{
+  string selectedText = "";
+  if( mController && mController->IsShowingRealText() )
+  {
+    selectedText = mController->GetSelectedText( );
   }
+  return selectedText;
 }
 
 void TextField::SetTextSelectionRange(const uint32_t *start, const uint32_t *end)
index 165234b..329d7b5 100755 (executable)
@@ -103,16 +103,6 @@ public:
    */
   Toolkit::TextField::InputStyleChangedSignalType& InputStyleChangedSignal();
 
-  /**
-   * @brief Called to select the whole texts.
-   */
-  void SelectWholeText();
-
-  /**
-   * @brief Called to unselect the whole texts.
-   */
-  void SelectNone();
-
 private: // From Control
 
   /**
@@ -217,6 +207,21 @@ public:
   Uint32Pair GetTextSelectionRange() const override;
 
   /**
+   * @copydoc Text::SelectableControlInterface::SelectWholeText()
+   */
+  void SelectWholeText() override;
+
+  /**
+   * @copydoc Text::SelectableControlInterface::SelectNone()
+   */
+  void SelectNone() override;
+
+  /**
+   * @copydoc Text::SelectableControlInterface::GetSelectedText()
+   */
+  string GetSelectedText() const override;
+
+  /**
    * @copydoc Text::EditableControlInterface::IsEditable()
    */
   bool IsEditable() const override;
index ca02bac..797ae32 100755 (executable)
@@ -3214,6 +3214,26 @@ Uint32Pair Controller::GetTextSelectionRange() const
   return mImpl->GetTextSelectionRange();
 }
 
+void Controller::SelectWholeText()
+{
+  SelectEvent( 0.f, 0.f, SelectionType::ALL );
+}
+
+void Controller::SelectNone()
+{
+  SelectEvent( 0.f, 0.f, SelectionType::NONE );
+}
+
+string Controller::GetSelectedText() const
+{
+  string text;
+  if( EventData::SELECTING == mImpl->mEventData->mState )
+  {
+    mImpl->RetrieveSelection( text, false );
+  }
+  return text;
+}
+
 InputMethodContext::CallbackData Controller::OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent )
 {
   // Whether the text needs to be relaid-out.
@@ -3926,16 +3946,6 @@ bool Controller::RemoveSelectedText()
   return textRemoved;
 }
 
-std::string Controller::GetSelectedText()
-{
-  std::string text;
-  if( EventData::SELECTING == mImpl->mEventData->mState )
-  {
-    mImpl->RetrieveSelection( text, false );
-  }
-  return text;
-}
-
 // private : Relayout.
 
 bool Controller::DoRelayout( const Size& size,
index e523dd2..3faab75 100755 (executable)
@@ -1506,6 +1506,21 @@ public: // Text-input Event Queuing.
   Uint32Pair GetTextSelectionRange() const;
 
   /**
+   * @copydoc Text::SelectableControlInterface::SelectWholeText()
+   */
+  void SelectWholeText();
+
+  /**
+   * @copydoc Text::SelectableControlInterface::SelectNone()
+   */
+  void SelectNone();
+
+  /**
+   * @copydoc Text::SelectableControlInterface::GetSelectedText()
+   */
+  string GetSelectedText() const;
+
+  /**
    * @copydoc Text::EditableControlInterface::IsEditable()
    */
   virtual bool IsEditable() const;
@@ -1543,13 +1558,6 @@ public: // Text-input Event Queuing.
    */
   Actor CreateBackgroundActor();
 
-  /**
-   * @brief Retrive Selected text.
-   *
-   * @return The seleced text.
-   */
-  std::string GetSelectedText();
-
 protected: // Inherit from Text::Decorator::ControllerInterface.
 
   /**
index fe70abb..65a35ca 100644 (file)
@@ -25,6 +25,7 @@ namespace Toolkit
 {
 
 using  Uint32Pair = std::pair<uint32_t,uint32_t>;
+using  string = std::string;
 namespace Text
 {
 
@@ -52,6 +53,22 @@ public:
    * @return pair contains start and end positions.
    */
   virtual Uint32Pair GetTextSelectionRange() const = 0;
+
+  /**
+   * @brief Called to select the whole texts.
+   */
+  virtual void SelectWholeText() = 0;
+
+  /**
+   * @brief Called to unselect the whole texts.
+   */
+  virtual void SelectNone() = 0;
+
+  /**
+   * @brief Retrive Selected text.
+   * @return The seletced text.
+   */
+  virtual string GetSelectedText() const = 0;
 };
 
 } // namespace Text