Revert "Renamed KeyEvent enum values to comply with coding standards."
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index c839ffd..0e482c9
@@ -22,6 +22,7 @@
 #include <cstring>
 #include <dali/public-api/adaptor-framework/key.h>
 #include <dali/devel-api/adaptor-framework/key-devel.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/object/property-helper-devel.h>
 #include <dali/devel-api/actors/actor-devel.h>
@@ -36,6 +37,8 @@
 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/controls/text-controls/autofill-container-impl.h>
 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
 #include <dali-toolkit/internal/text/text-effects-style.h>
@@ -1433,7 +1436,15 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
   Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
 
   // Support Right-To-Left of padding
-  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  Dali::LayoutDirection::Type layoutDirection;
+  if( mController->IsMatchSystemLanguageDirection() )
+  {
+    layoutDirection = static_cast<Dali::LayoutDirection::Type>( DevelWindow::Get( self ).GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  }
+  else
+  {
+    layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  }
   if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
   {
     std::swap( padding.start, padding.end );
@@ -1592,7 +1603,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
 void TextField::OnKeyInputFocusGained()
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
-  if ( mInputMethodContext )
+  if( mInputMethodContext )
   {
     mInputMethodContext.ApplyOptions( mInputMethodOptions );
 
@@ -1606,13 +1617,30 @@ void TextField::OnKeyInputFocusGained()
     // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
     mInputMethodContext.SetRestoreAfterFocusLost( true );
   }
-  ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
 
-  if ( notifier )
+  ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+  if( notifier )
   {
     notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
   }
 
+  Toolkit::Control control = Toolkit::Control::DownCast( Self() );
+  Internal::Control& controlImpl = GetImplementation( control );
+  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+  bool enableAutofill = controlDataImpl.IsAutofillEnabled();
+  if( enableAutofill )
+  {
+    Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer();
+    container.SetFocusedControl( control );
+
+    Internal::AutofillContainer& containerImpl = GetImpl( container );
+    Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup();
+    if( containerGroup != nullptr )
+    {
+      containerGroup.RequestAuthentication();
+    }
+
+  }
   mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
 
   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
@@ -1679,19 +1707,19 @@ void TextField::OnLongPress( const LongPressGesture& gesture )
 
 bool TextField::OnKeyEvent( const KeyEvent& event )
 {
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode() );
 
-  if( Dali::DALI_KEY_ESCAPE == event.keyCode && mController->ShouldClearFocusOnEscape() )
+  if( Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape() )
   {
     // Make sure ClearKeyInputFocus when only key is up
-    if( event.state == KeyEvent::Up )
+    if( event.GetState() == KeyEvent::Up )
     {
       ClearKeyInputFocus();
     }
 
     return true;
   }
-  else if( Dali::DevelKey::DALI_KEY_RETURN == event.keyCode )
+  else if( Dali::DevelKey::DALI_KEY_RETURN == event.GetKeyCode() )
   {
     // Do nothing when enter is comming.
     return false;
@@ -1868,7 +1896,7 @@ void TextField::OnSceneConnection( int depth )
 
 bool TextField::OnTouched( Actor actor, const TouchEvent& touch )
 {
-  return false;
+  return true;
 }
 
 void TextField::OnIdleSignal()