Set focus to web engine. 73/247773/5
authorhuayong.xu <huayong.xu@samsung.com>
Thu, 12 Nov 2020 06:54:28 +0000 (14:54 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Wed, 16 Dec 2020 10:56:53 +0000 (18:56 +0800)
When web view focus is gained, it is delivered to web engine.

Change-Id: I0ffdd895eab36390d4ad74bf38d5398153284a67

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.h

index 81b03dd38d27f1ed26e14ef49fc7a494d13a0887..372aec91d995140f9395d48ec0eb053da242fcf4 100755 (executable)
@@ -536,6 +536,10 @@ bool WebEngine::SendKeyEvent( const KeyEvent& event )
   return true;
 }
 
+void WebEngine::SetFocus( bool focused )
+{
+}
+
 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
 {
   return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
index adfa9f91f1c46644bd4ab304ac6f549cf41aff96..d9c34a615002c0640b1f6678762f8fe0fe6f025d 100644 (file)
@@ -254,6 +254,32 @@ int UtcDaliWebViewTouchAndKeys(void)
   END_TEST;
 }
 
+int UtcDaliWebViewFocusGainedAndLost(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  view.SetKeyInputFocus();
+  DALI_TEST_CHECK( view.HasKeyInputFocus() );
+
+  // reset
+  view.ClearKeyInputFocus();
+  DALI_TEST_CHECK( !view.HasKeyInputFocus() );
+
+  END_TEST;
+}
+
 int UtcDaliWebViewProperty1(void)
 {
   // URL
index c79e74ae46c0be9cef63e8a4338d45b23931d0be..1c9d9392eb685a552695aff68d5305a5519a1c9f 100644 (file)
@@ -541,6 +541,26 @@ bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
   return result;
 }
 
+void WebView::OnKeyInputFocusGained()
+{
+  if( mWebEngine )
+  {
+    mWebEngine.SetFocus( true );
+  }
+
+  EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
+}
+
+void WebView::OnKeyInputFocusLost()
+{
+  if( mWebEngine )
+  {
+    mWebEngine.SetFocus( false );
+  }
+
+  EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
+}
+
 Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
 {
   return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
index c41be87a0c32da8ef280637413f7f686e86e8494..968b7420d47bbb47526b19798745dce3295ba181 100644 (file)
@@ -213,6 +213,16 @@ private: // From Control
    */
   bool OnKeyEvent( const Dali::KeyEvent& event ) override;
 
+  /**
+   * @copydoc Toolkit::Control::OnKeyInputFocusGained()
+   */
+  void OnKeyInputFocusGained() override;
+
+  /**
+   * @copydoc Toolkit::Control::OnKeyInputFocusLost()
+   */
+  void OnKeyInputFocusLost() override;
+
 private:
 
   // Undefined