Dali-Text: Keyboard Shortcuts 28/242728/5
authorali <ali198724@gmail.com>
Mon, 31 Aug 2020 14:53:58 +0000 (17:53 +0300)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 11 Sep 2020 16:50:44 +0000 (16:50 +0000)
Add support for :
1- Select All Text : Ctrl+A
2- Copy Text: support Ctrl+Insert
Disable Ctrl+(C/X/V/A/Insert) when shift is down

Change-Id: I5404ac6866eedb13ba2091d1d4b1be7e70dd95a8

automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
dali-toolkit/internal/text/text-controller.cpp

index cb8d8bb..1f80374 100644 (file)
@@ -2157,6 +2157,23 @@ int utcDaliTextEditorEvent07(void)
   // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
 
+  // Select all Text
+  application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // replace text with "c"
+  application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  //text is "c"
+  DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
   END_TEST;
 }
 
index 4edac33..48036ad 100755 (executable)
@@ -53,6 +53,8 @@ const std::string EMPTY_STRING("");
 const std::string KEY_C_NAME = "c";
 const std::string KEY_V_NAME = "v";
 const std::string KEY_X_NAME = "x";
+const std::string KEY_A_NAME = "a";
+const std::string KEY_INSERT_NAME = "Insert";
 
 const char * const PLACEHOLDER_TEXT = "text";
 const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
@@ -2905,12 +2907,12 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
       // Do nothing
       return false;
     }
-    else if ( keyEvent.IsCtrlModifier() )
+    else if ( keyEvent.IsCtrlModifier() && !keyEvent.IsShiftModifier())
     {
       bool consumed = false;
-      if (keyName == KEY_C_NAME)
+      if (keyName == KEY_C_NAME || keyName == KEY_INSERT_NAME)
       {
-        // Ctrl-C to copy the selected text
+        // Ctrl-C or Ctrl+Insert to copy the selected text
         TextPopupButtonTouched( Toolkit::TextSelectionPopup::COPY );
         consumed = true;
       }
@@ -2926,6 +2928,12 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
         TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT );
         consumed = true;
       }
+      else if (keyName == KEY_A_NAME)
+      {
+        // Ctrl-A to select All the text
+        TextPopupButtonTouched( Toolkit::TextSelectionPopup::SELECT_ALL );
+        consumed = true;
+      }
       return consumed;
     }
     else if( ( Dali::DALI_KEY_BACKSPACE == keyCode ) ||