From: huayong.xu Date: Thu, 12 Nov 2020 06:54:28 +0000 (+0800) Subject: Set focus to web engine. X-Git-Tag: dali_2.0.8~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c81ee521e33d47e386d60eb7ccf07b98073542c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Set focus to web engine. When web view focus is gained, it is delivered to web engine. Change-Id: I0ffdd895eab36390d4ad74bf38d5398153284a67 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 81b03dd38d..372aec91d9 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -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(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index adfa9f91f1..d9c34a6150 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -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 diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp index c79e74ae46..1c9d9392eb 100644 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -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; diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h index c41be87a0c..968b7420d4 100644 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -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