From b41291b99ff6797ff1d8382e0497c8f186a2dee7 Mon Sep 17 00:00:00 2001 From: hyun lee Date: Tue, 16 Jul 2013 10:10:53 +0900 Subject: [PATCH] Fix for issue about focus ui Change-Id: If919007bffdf2d19442f30f3bcb98b41c46b2f29 Signed-off-by: hyun lee --- src/controls/FWebCtrl_Web.cpp | 58 +++++++++++++++++++++++++++++++++++++++ src/controls/FWebCtrl_Web.h | 9 ++++++ src/controls/FWebCtrl_WebImpl.cpp | 28 +++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/src/controls/FWebCtrl_Web.cpp b/src/controls/FWebCtrl_Web.cpp index 74782d2..9d97cb9 100755 --- a/src/controls/FWebCtrl_Web.cpp +++ b/src/controls/FWebCtrl_Web.cpp @@ -340,6 +340,7 @@ _Web::_Web(void) , __pPinchGestureHandler(null) , __gestureType(WEB_GESTURE_TYPE_TAP) , __edgeType(WEB_EDGE_NONE) + , __focus(false) , __pTextElement(null) , __previousTouchedPosition(0.0f, 0.0f) { @@ -691,6 +692,63 @@ _Web::SetEdgeReachedEvent(_WebEdgeType type) } +void +_Web::SetFocusEnd(bool focus) +{ + __focus = focus; +} + + +bool +_Web::IsFocusEnd(void) +{ + return __focus; +} + + +bool +_Web::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + _KeyCode keyCode = keyInfo.GetKeyCode(); + Evas* pEvas = evas_object_evas_get(GetWebNativeNode()); + + if (IsFocusEnd() == true) + { + SetFocusEnd(false); + evas_object_focus_set(GetWebNativeNode(), EINA_FALSE); + return false; + } + + switch(keyCode) + { + case _KEY_UP: + case _KEY_DOWN: + evas_object_focus_set(GetWebNativeNode(), EINA_FALSE); + return false; + break; + default: + break; + } + + evas_object_focus_set(GetWebNativeNode(), EINA_TRUE); + + return true; +} + + +bool +_Web::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return false; +} + + +void +_Web::OnDrawFocus(void) +{ +} + + bool _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { diff --git a/src/controls/FWebCtrl_Web.h b/src/controls/FWebCtrl_Web.h index a1878ae..bf6fa51 100755 --- a/src/controls/FWebCtrl_Web.h +++ b/src/controls/FWebCtrl_Web.h @@ -115,9 +115,16 @@ public: void SetEdgeReachedEvent(_WebEdgeType type); + void SetFocusEnd(bool focus); + bool IsFocusEnd(void); + virtual result OnAttaching(const _Control* pParent); virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual bool OnKeyPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo); + virtual bool OnKeyReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo); + virtual void OnDrawFocus(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); @@ -193,6 +200,8 @@ private: int __edgeType; + bool __focus; + Tizen::Ui::_AccessibilityElement* __pTextElement; Tizen::Graphics::FloatPoint __previousTouchedPosition; diff --git a/src/controls/FWebCtrl_WebImpl.cpp b/src/controls/FWebCtrl_WebImpl.cpp index 073b09a..0f7e88e 100755 --- a/src/controls/FWebCtrl_WebImpl.cpp +++ b/src/controls/FWebCtrl_WebImpl.cpp @@ -856,6 +856,28 @@ OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo) void +OnFocusDownRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + //pWebCore->SetFocusEnd(true); +} + + +void +OnFocusUpRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + //pWebCore->SetFocusEnd(true); +} + + +void OnVibrationRequested(uint64_t duration, void* pUserData) { result r = E_SUCCESS; @@ -3649,6 +3671,9 @@ _WebImpl::SetEventListenerCallback(void) const evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this); evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this); + evas_object_smart_callback_add(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested, this); + ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this)); Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode); SysAssertf(pContext, "Failed to get webkit instance."); @@ -3733,6 +3758,9 @@ _WebImpl::RemoveEventListenerCallback(void) const evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered); evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited); + evas_object_smart_callback_del(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested); + evas_object_smart_callback_del(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested); + ewk_view_open_panel_callback_set(null, null, null); Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode); SysAssertf(pContext, "Failed to get webkit instance."); -- 2.7.4