[Tizen]Add ClearFocusOnEscape to config section. 27/147127/1 accepted/tizen/4.0/unified/20170907.192405 submit/tizen_4.0/20170901.082413 submit/tizen_4.0/20170907.133944
authorminho.sun <minho.sun@samsung.com>
Fri, 1 Sep 2017 04:58:32 +0000 (13:58 +0900)
committerminho.sun <minho.sun@samsung.com>
Fri, 1 Sep 2017 05:52:02 +0000 (14:52 +0900)
This value indicates whether text control clear key input focus or not
when escape key is pressed.

Change-Id: Ifc9680d4de3a9d8eba83463b91ba5f349f4b36ef
Signed-off-by: minho.sun <minho.sun@samsung.com>
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json

index ca6f5ab..333e8ec 100755 (executable)
@@ -1484,7 +1484,8 @@ bool TextEditor::OnKeyEvent( const KeyEvent& event )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
 
-  if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this
+  if( Dali::DALI_KEY_ESCAPE == event.keyCode
+      && mController->IsClearFocusOnEscape() )
   {
     // Make sure ClearKeyInputFocus when only key is up
     if( event.state == KeyEvent::Up )
index 1ed87bd..d73f170 100644 (file)
@@ -1526,7 +1526,8 @@ 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 ) // Make a Dali key code for this
+  if( Dali::DALI_KEY_ESCAPE == event.keyCode
+      && mController->IsClearFocusOnEscape() )
   {
     // Make sure ClearKeyInputFocus when only key is up
     if( event.state == KeyEvent::Up )
index 054f4a7..9c48ed1 100644 (file)
@@ -27,6 +27,8 @@
 #include <dali-toolkit/internal/text/text-controller.h>
 #include <dali-toolkit/internal/text/text-model.h>
 #include <dali-toolkit/internal/text/text-view.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
 
 namespace Dali
 {
@@ -336,6 +338,14 @@ struct Controller::Impl
     // Set the text properties to default
     mModel->mVisualModel->SetUnderlineEnabled( false );
     mModel->mVisualModel->SetUnderlineHeight( 0.0f );
+
+    Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+    if( styleManager )
+    {
+      Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+      mIsClearFocusOnEscape = config["clearFocusOnEscape"].Get<bool>();
+    }
+
   }
 
   ~Impl()
@@ -730,6 +740,7 @@ public:
   bool mUnderlineSetByString:1;            ///< Set when underline is set by string (legacy) instead of map
   bool mShadowSetByString:1;               ///< Set when shadow is set by string (legacy) instead of map
   bool mFontStyleSetByString:1;            ///< Set when font style is set by string (legacy) instead of map
+  bool mIsClearFocusOnEscape:1;            ///< Whether text control clear key input focus or not
 };
 
 } // namespace Text
index 8b0ee5b..c7b8a59 100644 (file)
@@ -2222,13 +2222,10 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
       // Do nothing.
       return false;
     }
-    else if( Dali::DALI_KEY_ESCAPE == keyCode )
+    else if( Dali::DALI_KEY_ESCAPE == keyCode || Dali::DALI_KEY_BACK )
     {
-      // Escape key is a special case which causes focus loss
-      KeyboardFocusLostEvent();
-
-      // Will request for relayout.
-      relayoutNeeded = true;
+      // Do nothing
+      return false;
     }
     else if( ( Dali::DALI_KEY_CURSOR_LEFT  == keyCode ) ||
              ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) ||
@@ -3688,6 +3685,11 @@ void Controller::SetControlInterface( ControlInterface* controlInterface )
   mImpl->mControlInterface = controlInterface;
 }
 
+bool Controller::IsClearFocusOnEscape()
+{
+  return mImpl->mIsClearFocusOnEscape;
+}
+
 // private : Private contructors & copy operator.
 
 Controller::Controller()
index 5cb079c..0913cb5 100644 (file)
@@ -1180,6 +1180,13 @@ public: // Text-input Event Queuing.
    */
   void PasteClipboardItemEvent();
 
+  /**
+   * @brief Return whether text control clear key input focus or not when escape key is pressed.
+   *
+   * @return Whether text control clear key input focus or not
+   */
+  bool IsClearFocusOnEscape();
+
 protected: // Inherit from Text::Decorator::ControllerInterface.
 
   /**
index 7debf95..50f9529 100644 (file)
@@ -28,7 +28,8 @@
 {
   "config":
   {
-    "alwaysShowFocus":true
+    "alwaysShowFocus":true,
+    "clearFocusOnEscape":false
   },
   "styles":
   {
index 8612b3c..460d0f8 100644 (file)
@@ -28,7 +28,8 @@
 {
   "config":
   {
-    "alwaysShowFocus":false
+    "alwaysShowFocus":false,
+    "clearFocusOnEscape":true
   },
   "styles":
   {
index 0c48655..9390546 100644 (file)
@@ -28,7 +28,8 @@
 {
   "config":
   {
-    "alwaysShowFocus":false
+    "alwaysShowFocus":false,
+    "clearFocusOnEscape":true
   },
   "styles":
   {