Clear input focus when Return/Escape key Up 92/116092/2
authorminho.sun <minho.sun@samsung.com>
Thu, 23 Feb 2017 02:20:56 +0000 (11:20 +0900)
committerminho.sun <minho.sun@samsung.com>
Mon, 27 Feb 2017 14:31:22 +0000 (23:31 +0900)
Make TextField and TextEditor clear it's input focus when getting Return/Escape KeyUp event.

Change-Id: I62053850dc198da0f9d6a241aac586b67f1d6d88
Signed-off-by: minho.sun <minho.sun@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp

index cd9d6bf..4635def 100644 (file)
@@ -1603,5 +1603,12 @@ int utcDaliTextEditorEvent05(void)
   DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
 
+  // Press Escape to increase coverage
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
+
   END_TEST;
 }
index aee824b..1ea11be 100644 (file)
@@ -2014,5 +2014,12 @@ int utcDaliTextFieldStyleWhilstSelected(void)
   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
 
+  // Press Escape to increase coverage
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( !field.HasKeyInputFocus() );
+
   END_TEST;
 }
index b6d9900..469ea3e 100644 (file)
@@ -1259,7 +1259,12 @@ bool TextEditor::OnKeyEvent( const KeyEvent& event )
 
   if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this
   {
-    ClearKeyInputFocus();
+    // Make sure ClearKeyInputFocus when only key is up
+    if( event.state == KeyEvent::Up )
+    {
+      ClearKeyInputFocus();
+    }
+
     return true;
   }
 
index 6a846e4..a32e7f5 100644 (file)
@@ -1403,10 +1403,14 @@ bool TextField::OnKeyEvent( const KeyEvent& event )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
 
-  if( Dali::DALI_KEY_ESCAPE == event.keyCode ||
-      "Return" == event.keyPressedName ) // Make a Dali key code for this
+  if( Dali::DALI_KEY_ESCAPE == event.keyCode || "Return" == event.keyPressedName ) // Make a Dali key code for this
   {
-    ClearKeyInputFocus();
+    // Make sure ClearKeyInputFocus when only key is up
+    if( event.state == KeyEvent::Up )
+    {
+      ClearKeyInputFocus();
+    }
+
     return true;
   }