support H/W key on ContextMenu
authorPark Kyoung Hee <kh1979.park@samsung.com>
Wed, 26 Jun 2013 07:01:26 +0000 (16:01 +0900)
committerPark Kyoung Hee <kh1979.park@samsung.com>
Thu, 27 Jun 2013 08:03:48 +0000 (17:03 +0900)
fix scrolling when FocusUI on ContextMenu
fix memory leak on ContextMenu

Change-Id: If2e3589e29157c153139104f56209f91ba0c9d6e
Signed-off-by: Park Kyoung Hee <kh1979.park@samsung.com>
src/ui/controls/FUiCtrl_ContextMenu.cpp
src/ui/controls/FUiCtrl_ContextMenuGridPresenter.cpp
src/ui/controls/FUiCtrl_ContextMenuItem.cpp
src/ui/controls/FUiCtrl_ContextMenuListPresenter.cpp
src/ui/inc/FUiCtrl_ContextMenu.h
src/ui/inc/FUiCtrl_ContextMenuGridPresenter.h
src/ui/inc/FUiCtrl_ContextMenuListPresenter.h

index 773ba8b..53f460c 100644 (file)
@@ -25,6 +25,7 @@
 #include <FBaseColIEnumeratorT.h>
 #include "FUi_ControlImplManager.h"
 #include "FUi_ResourceManager.h"
+#include "FUi_KeyEventManager.h"
 #include "FUiAnim_VisualElement.h"
 #include "FUiAnim_AnimationManager.h"
 #include "FUi_AccessibilityContainer.h"
@@ -45,6 +46,65 @@ static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
 namespace Tizen { namespace Ui { namespace Controls
 {
 
+class _ContextMenu::_ContextMenuHwKeyEventListener
+       : public _IKeyEventListener
+       , virtual public _IUiEventListener
+       , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+               _ContextMenuHwKeyEventListener(_ContextMenu* pContextMenu)
+               {
+                       __pContextMenu = pContextMenu;
+               }
+
+               virtual ~_ContextMenuHwKeyEventListener(void)
+               {
+               }
+
+               virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+               {
+                       _KeyCode keyCode = keyInfo.GetKeyCode();
+
+                       switch (keyCode) {
+                               case _KEY_MENU:
+                                       // fall through
+                               case _KEY_CONTEXT_MENU:
+                                       // fall through
+                               case _KEY_ESC:
+                                       // fall through
+                               case _KEY_BACK:
+                                       return __pContextMenu->__pContextMenuPresenter->OnKeyPressed(source, keyInfo);
+                               default:
+                                       return false;
+                       }
+               }
+
+               virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+               {
+                       _KeyCode keyCode = keyInfo.GetKeyCode();
+
+                       switch (keyCode) {
+                               case _KEY_MENU:
+                                       // fall through
+                               case _KEY_CONTEXT_MENU:
+                                       // fall through
+                               case _KEY_ESC:
+                                       // fall through
+                               case _KEY_BACK:
+                                       return __pContextMenu->__pContextMenuPresenter->OnKeyReleased(source, keyInfo);
+                               default:
+                                       return false;
+                       }
+               }
+
+private:
+               _ContextMenuHwKeyEventListener(const _ContextMenu& rhs);
+               _ContextMenuHwKeyEventListener& operator =(const _ContextMenu& rhs);
+
+private:
+               _ContextMenu* __pContextMenu;
+};     // _ContextMenuHwKeyEventListener
+
 IMPLEMENT_PROPERTY(_ContextMenu);
 
 _ContextMenu::_ContextMenu(const FloatPoint& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign)
@@ -67,6 +127,7 @@ _ContextMenu::_ContextMenu(const FloatPoint& point, enum ContextMenuCoreStyle st
        , __layout(_CONTROL_ORIENTATION_PORTRAIT)
        , __rotation(_CONTROL_ROTATION_0)
        , __pScrollPanel(null)
+       , __pHwKeyEventListener(null)
 {
        __backgroundColor = Color(255, 255, 255, 255);
 
@@ -94,6 +155,13 @@ _ContextMenu::~_ContextMenu(void)
                GetOwner()->UnlockInputEvent();
        }
 
+       if (__pHwKeyEventListener != null)
+       {
+               _KeyEventManager::GetInstance()->RemoveKeyEventListener(*__pHwKeyEventListener);
+               delete __pHwKeyEventListener;
+               __pHwKeyEventListener = null;
+       }
+
        if (__pScrollPanel) {
                __pScrollPanel->DetachAllChildren();
                DetachChild(*__pScrollPanel);
@@ -318,10 +386,28 @@ _ContextMenu::OnAttachedToMainTree(void)
        r = __pContextMenuPresenter->CalculateWindowRect();
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
+       if (__pScrollPanel != null)
+       {
+               __pScrollPanel->SetScrollPosition(0.0f, false);
+       }
+
        r = Open();
 
        SetVisibleState(true);
 
+       if (!this->IsFocusable())
+       {
+               if (__pHwKeyEventListener == null)
+               {
+                       __pHwKeyEventListener = new (std::nothrow) _ContextMenuHwKeyEventListener(this);
+               }
+
+               if (__pHwKeyEventListener != null)
+               {
+                       _KeyEventManager::GetInstance()->AddKeyEventListener(*__pHwKeyEventListener);
+               }
+       }
+
        if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
        {
                SetTouchCapture(false, false);
@@ -383,6 +469,11 @@ _ContextMenu::OnDetachingFromMainTree(void)
 {
        result r = E_SUCCESS;
 
+       if (__pHwKeyEventListener != null)
+       {
+               _KeyEventManager::GetInstance()->RemoveKeyEventListener(*__pHwKeyEventListener);
+       }
+
        ReleaseTouchCapture();
 
        _Control* pOwner = GetOwner();
index d9a123e..0e56790 100644 (file)
@@ -83,6 +83,7 @@ _ContextMenuGridPresenter::_ContextMenuGridPresenter(_ContextMenu* pContextMenu)
        , __bgPressedMargin(0.0f)
        , __anchorPopupOverlap(0.0f)
        , __enterKeyPressed(false)
+       , __backKeyPressed(false)
        , __focusedIndex(-1)
 {
 
@@ -1407,15 +1408,24 @@ _ContextMenuGridPresenter::DrawItem(Tizen::Graphics::Canvas* pCanvas)
                {
                        FloatRectangle pressedDrawRect = pItem->GetPressedDrawRect();
 
+                       Color contentHighlightedColor;
+                       GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
                        Bitmap* pBitmap = null;
-                       result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
-                       SysTryReturn(NID_UI_CTRL, pBitmap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
+                       Bitmap* pTempBitmap = null;
+                       result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
+                       SysTryReturn(NID_UI_CTRL, pTempBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
                        if (r == E_SUCCESS)
                        {
-                               DrawBitmap(*pCanvas, pressedDrawRect, *pBitmap);
+                               pBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
+                               if (pBitmap != null)
+                               {
+                                       DrawBitmap(*pCanvas, pressedDrawRect, *pBitmap);
+                               }
                        }
 
+                       delete pTempBitmap;
+                       pTempBitmap = null;
+
                        delete pBitmap;
                        pBitmap = null;
                }
@@ -1529,6 +1539,7 @@ _ContextMenuGridPresenter::OnTouchReleased(const _Control& source, const _TouchI
                {
                        __selectedIndex = -1;
                        __pressedIndex = -1;
+                       __focusedIndex = -1;
                        __pContextMenu->SetFocused(false);
                        __pContextMenu->SetVisibleState(false);
                        return true;
@@ -1536,6 +1547,7 @@ _ContextMenuGridPresenter::OnTouchReleased(const _Control& source, const _TouchI
 
                __selectedIndex = -1;
                __pressedIndex = -1;
+               __focusedIndex = -1;
 
                int actionId = pItem->GetActionId();
 
@@ -1629,19 +1641,23 @@ _ContextMenuGridPresenter::OnKeyPressed(const _Control& source, const _KeyInfo&
                // fall through
        case _KEY_UP:
        {
+               if (__focusedIndex == -1)
+               {
+                       break;
+               }
+
                if (__enterKeyPressed)
                {
                        __enterKeyPressed = false;
                        __selectedIndex = -1;
                }
 
-               if (__focusedIndex <= 0)
+               _ContextMenuItem* pItem = __pModel->GetItem(--__focusedIndex);
+               if (pItem == null)
                {
+                       __focusedIndex++;
                        break;
                }
-
-               --__focusedIndex;
-               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
                pItem->SetFocused(true);
                Draw();
 
@@ -1651,19 +1667,23 @@ _ContextMenuGridPresenter::OnKeyPressed(const _Control& source, const _KeyInfo&
                // fall through
        case _KEY_DOWN:
        {
+               if (__focusedIndex == -1)
+               {
+                       break;
+               }
+
                if (__enterKeyPressed)
                {
                        __enterKeyPressed = false;
                        __selectedIndex = -1;
                }
 
-               if (__focusedIndex >= __pModel->GetItemCount() - 1)
+               _ContextMenuItem* pItem = __pModel->GetItem(++__focusedIndex);
+               if (pItem == null)
                {
+                       __focusedIndex--;
                        break;
                }
-
-               ++__focusedIndex;
-               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
                pItem->SetFocused(true);
                Draw();
 
@@ -1671,14 +1691,14 @@ _ContextMenuGridPresenter::OnKeyPressed(const _Control& source, const _KeyInfo&
        }
        case _KEY_ENTER:
        {
+               __enterKeyPressed = true;
+
                if (__focusedIndex == -1)
                {
-                       return true;
+                       break;
                }
 
-               __enterKeyPressed = true;
                __selectedIndex = __focusedIndex;
-
                _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
                pItem->SetFocused(true);
                Draw();
@@ -1687,24 +1707,32 @@ _ContextMenuGridPresenter::OnKeyPressed(const _Control& source, const _KeyInfo&
        }
        case _KEY_BACKSPACE:
        {
-               if (__focusedIndex == -1)
-               {
-                       return true;
-               }
-
                _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
                if (pItem != null)
                {
                        pItem->SetFocused(false);
                }
+
                __enterKeyPressed = false;
+               __backKeyPressed = false;
+               __pressedIndex = -1;
                __selectedIndex = -1;
                __focusedIndex = -1;
 
                __pContextMenu->SetFocused(false);
                __pContextMenu->SetVisibleState(false);
+
                break;
        }
+       case _KEY_ESC:
+               // fall through
+       case _KEY_MENU:
+               // fall through
+       case _KEY_CONTEXT_MENU:
+               // fall through
+       case _KEY_BACK:
+               __backKeyPressed = true;
+               break;
        default:
                return false;
        }
@@ -1728,7 +1756,7 @@ _ContextMenuGridPresenter::OnKeyReleased(const _Control& source, const _KeyInfo&
        case _KEY_DOWN:
                // fall through
        case _KEY_BACKSPACE:
-               return true;
+               break;
        case _KEY_ENTER:
        {
                if (!__enterKeyPressed)
@@ -1737,15 +1765,7 @@ _ContextMenuGridPresenter::OnKeyReleased(const _Control& source, const _KeyInfo&
                }
 
                __enterKeyPressed = false;
-
-               _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
-
-               if (pActionEvent == null)
-               {
-                       __pContextMenu->SetFocused(false);
-                       __pContextMenu->SetVisibleState(false);
-                       return true;
-               }
+               __backKeyPressed =  false;
 
                _ContextMenuItem* pItem = __pModel->GetItem(__selectedIndex);
                if (pItem == null)
@@ -1753,37 +1773,68 @@ _ContextMenuGridPresenter::OnKeyReleased(const _Control& source, const _KeyInfo&
                        __selectedIndex = -1;
                        __pressedIndex = -1;
                        __focusedIndex = -1;
-                       pItem->SetFocused(false);
                        __pContextMenu->SetFocused(false);
                        __pContextMenu->SetVisibleState(false);
-                       return true;
+
+                       break;
+               }
+
+               int actionId = pItem->GetActionId();
+
+               _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
+               if (pActionEvent == null)
+               {
+                       break;
+               }
+
+               IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+               if (pEventArg == null)
+               {
+                       break;
                }
 
+               pActionEvent->Fire(*pEventArg);
+
                __selectedIndex = -1;
                __pressedIndex = -1;
                __focusedIndex = -1;
+               pItem->SetFocused(false);
+               __pContextMenu->SetFocused(false);
+               __pContextMenu->SetVisibleState(false);
 
-               int actionId = pItem->GetActionId();
-
-               IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+               break;
+       }
+       case _KEY_ESC:
+               // fall through
+       case _KEY_MENU:
+               // fall through
+       case _KEY_CONTEXT_MENU:
+               // fall through
+       case _KEY_BACK:
+       {
+               if (!__backKeyPressed)
+               {
+                       return true;
+               }
 
-               if (pEventArg == null)
+               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+               if (pItem != null)
                {
                        pItem->SetFocused(false);
-                       __pContextMenu->SetFocused(false);
-                       __pContextMenu->SetVisibleState(false);
-                       return true;
                }
 
-               pItem->SetFocused(false);
+               __enterKeyPressed = false;
+               __backKeyPressed = false;
+               __selectedIndex = -1;
+               __pressedIndex = -1;
+               __focusedIndex = -1;
                __pContextMenu->SetFocused(false);
                __pContextMenu->SetVisibleState(false);
-               pActionEvent->Fire(*pEventArg);
 
                break;
        }
        default:
-                       return false;
+               return false;
        }
 
        return true;
@@ -1798,8 +1849,12 @@ _ContextMenuGridPresenter::IsChildControlFocusManage(void) const
 void
 _ContextMenuGridPresenter::OnDrawFocus(void)
 {
-       __focusedIndex = 0;
+       if (__focusedIndex == -1)
+       {
+               __focusedIndex = 0;
+       }
        __selectedIndex = -1;
+
        Draw();
 }
 
index d8a18a4..29628c9 100644 (file)
@@ -124,6 +124,12 @@ _ContextMenuItem::~_ContextMenuItem(void)
                __pLowerDividerLineLabel = null;
        }
 
+       delete __pTextLabel;
+       __pTextLabel = null;
+
+       delete __pBitmapLabel;
+       __pBitmapLabel = null;
+
        _AccessibilityContainer* pContainer = GetAccessibilityContainer();
        if (pContainer)
        {
index 120d63b..b98af3a 100644 (file)
@@ -84,6 +84,8 @@ _ContextMenuListPresenter::_ContextMenuListPresenter(_ContextMenu* pContextMenu)
        , __dividerHeight(0.0f)
        , __anchorPopupOverlap(0.0f)
        , __enterKeyPressed(false)
+       , __backKeyPressed(false)
+       , __focusedIndex(-1)
 {
 
 }
@@ -998,6 +1000,7 @@ _ContextMenuListPresenter::OnTouchReleased(const _Control& source, const _TouchI
                if (!itemRect.Contains(touchPosition))
                {
                        __selectedIndex = -1;
+                       __focusedIndex = -1;
                        __pContextMenu->SetFocused(false);
                        __pContextMenu->SetVisibleState(false);
 
@@ -1012,6 +1015,7 @@ _ContextMenuListPresenter::OnTouchReleased(const _Control& source, const _TouchI
                pItem = __pModel->GetItem(__selectedIndex);
 
                __selectedIndex = -1;
+               __focusedIndex = -1;
                __pContextMenu->SetFocused(false);
                __pContextMenu->SetVisibleState(false);
 
@@ -1072,118 +1076,110 @@ bool
 _ContextMenuListPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
 {
        _KeyCode keyCode = keyInfo.GetKeyCode();
-       _Control* pFocusedControl = null;
-       _Window* pTop = source.GetRootWindow();
-       if (pTop)
-       {
-               pFocusedControl = pTop->GetCurrentFocusControl();
-       }
-
-       int focusedIndex = -1;
-
-       for (int i = 0; i < __pModel->GetItemCount(); i++)
-       {
-               _ContextMenuItem* pItem = __pModel->GetItem(i);
-               if (pFocusedControl == pItem)
-               {
-                       focusedIndex = i;
-                       break;
-               }
-       }
 
        switch (keyCode)
        {
        case _KEY_UP:
        {
-               if (focusedIndex == -1)
+               if (__focusedIndex == -1)
                {
-                       return true;
+                       break;
                }
 
                if (__enterKeyPressed)
                {
                        __enterKeyPressed = false;
-                       _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
-                       pItem->SetAndInvalidate(false);
+                       _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+                       if (pItem != null)
+                       {
+                               pItem->SetAndInvalidate(false);
+                       }
                }
 
-               if (focusedIndex <= 0)
+               _ContextMenuItem* pItem = __pModel->GetItem(--__focusedIndex);
+               if(pItem == null)
                {
+                       __focusedIndex++;
                        break;
                }
 
-               _ContextMenuItem* pItem = __pModel->GetItem(--focusedIndex);
-               if(pItem != null)
-               {
-                       pItem->SetFocused(true);
-                       pItem->DrawFocus();
-               }
+               pItem->SetFocused(true);
+               pItem->DrawFocus();
+               __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
+
                break;
        }
        case _KEY_DOWN:
        {
-               if (focusedIndex == -1)
+               if (__focusedIndex == -1)
                {
-                       return true;
+                       break;
                }
 
                if (__enterKeyPressed)
                {
                        __enterKeyPressed = false;
-                       _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
-                       pItem->SetAndInvalidate(false);
+                       _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+                       if(pItem != null)
+                       {
+                               pItem->SetAndInvalidate(false);
+                       }
                }
 
-               if (focusedIndex >= __pModel->GetItemCount() - 1)
+               _ContextMenuItem* pItem = __pModel->GetItem(++__focusedIndex);
+               if(pItem == null)
                {
+                       __focusedIndex--;
                        break;
                }
 
-               _ContextMenuItem* pItem = __pModel->GetItem(++focusedIndex);
-               if(pItem != null)
-               {
-                       pItem->SetFocused(true);
-                       pItem->DrawFocus();
-               }
+               pItem->SetFocused(true);
+               pItem->DrawFocus();
+               __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
+
                break;
        }
        case _KEY_ENTER:
        {
-               if (focusedIndex == -1)
+               __enterKeyPressed = true;
+
+               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+               if(pItem != null)
                {
-                       return true;
+                       pItem->SetAndInvalidate(true);
                }
 
-               __enterKeyPressed = true;
-               _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
-               pItem->SetAndInvalidate(true);
-
                break;
        }
        case _KEY_BACKSPACE:
        {
-               if (focusedIndex == -1)
-               {
-                       return true;
-               }
-
-               _ContextMenuItem* pItem = __pModel->GetItem(focusedIndex);
+               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
                if (pItem != null)
                {
-                       pItem->SetAndInvalidate(false);
                        pItem->SetFocused(false);
-                       pItem->DrawFocus();
                        pItem->SetAndInvalidate(false);
                }
 
                __enterKeyPressed = false;
+               __backKeyPressed = false;
                __selectedIndex = -1;
+               __focusedIndex = -1;
                __pContextMenu->SetFocused(false);
                __pContextMenu->SetVisibleState(false);
+
                break;
        }
+       case _KEY_ESC:
+               // fall through
+       case _KEY_MENU:
+               // fall through
+       case _KEY_CONTEXT_MENU:
+               // fall through
+       case _KEY_BACK:
+               __backKeyPressed = true;
+               break;
        default:
-                       return false;
+               return false;
        }
 
        return true;
@@ -1201,7 +1197,7 @@ _ContextMenuListPresenter::OnKeyReleased(const _Control& source, const _KeyInfo&
        case _KEY_DOWN:
                // fall through
        case _KEY_BACKSPACE:
-               return true;
+               break;
        case _KEY_ENTER:
        {
                if (!__enterKeyPressed)
@@ -1210,58 +1206,77 @@ _ContextMenuListPresenter::OnKeyReleased(const _Control& source, const _KeyInfo&
                }
 
                __enterKeyPressed = false;
+               __backKeyPressed = false;
+
+               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
 
-               _Control* pFocusedControl = null;
-               _Window* pTop = source.GetRootWindow();
-               if (pTop)
+               if (pItem == null)
                {
-                       pFocusedControl = pTop->GetCurrentFocusControl();
+                       __selectedIndex = -1;
+                       __focusedIndex = -1;
+                       __pContextMenu->SetFocused(false);
+                       __pContextMenu->SetVisibleState(false);
+
+                       break;
                }
 
-               _ContextMenuItem* pItem = null;
+               int actionId = pItem->GetActionId();
 
-               for (int i = 0; i < __pModel->GetItemCount(); i++)
+               _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
+               if (pActionEvent == null)
                {
-                       pItem = __pModel->GetItem(i);
-                       if (pFocusedControl == pItem)
-                       {
-                               break;
-                       }
+                       break;
                }
 
-               if (pItem == null)
+               IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+               if (pEventArg == null)
                {
-                       return false;
+                       break;
                }
 
+               pActionEvent->Fire(*pEventArg);
+
                pItem->SetFocused(false);
-               pItem->DrawFocus();
                pItem->SetAndInvalidate(false);
 
                __selectedIndex = -1;
+               __focusedIndex = -1;
                __pContextMenu->SetFocused(false);
                __pContextMenu->SetVisibleState(false);
 
-               int actionId = pItem->GetActionId();
-
-               _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
-               if (pActionEvent == null)
+               break;
+       }
+       case _KEY_ESC:
+               // fall through
+       case _KEY_MENU:
+               // fall through
+       case _KEY_CONTEXT_MENU:
+               // fall through
+       case _KEY_BACK:
+       {
+               if (!__backKeyPressed)
                {
                        return true;
                }
 
-               IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
-               if (pEventArg == null)
+               _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+               if (pItem != null)
                {
-                       return true;
+                       pItem->SetFocused(false);
+                       pItem->SetAndInvalidate(false);
                }
 
-               pActionEvent->Fire(*pEventArg);
+               __enterKeyPressed = false;
+               __backKeyPressed = false;
+               __selectedIndex = -1;
+               __focusedIndex = -1;
+               __pContextMenu->SetFocused(false);
+               __pContextMenu->SetVisibleState(false);
 
                break;
        }
        default:
-                       return false;
+               return false;
        }
 
        return true;
@@ -1271,16 +1286,24 @@ bool
 _ContextMenuListPresenter::IsChildControlFocusManage(void) const
 {
        return true;
+
 }
 
 void
 _ContextMenuListPresenter::OnDrawFocus(void)
 {
-       _ContextMenuItem* pItem = __pModel->GetItem(0);
+       _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
+       if (pItem == null)
+       {
+               __focusedIndex = 0;
+               pItem = __pModel->GetItem(__focusedIndex);
+       }
+
        if (pItem != null)
        {
                pItem->SetFocused(true);
                pItem->DrawFocus();
+               __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
        }
 }
 
index 4026e8e..5ed7f85 100644 (file)
@@ -286,6 +286,8 @@ private:
 
        _ScrollPanel* __pScrollPanel;
 
+       class _ContextMenuHwKeyEventListener;
+       _ContextMenuHwKeyEventListener* __pHwKeyEventListener;
 }; // _ContextMenu
 
 }}} // Tizen::Ui: Control
index dbec523..d10be74 100644 (file)
@@ -156,6 +156,7 @@ private:
        float __anchorPopupOverlap;
 
        bool __enterKeyPressed;
+       bool __backKeyPressed;
        int __focusedIndex;
 }; // _ContextMenuGridPresenter
 
index a8d73ab..6e9031e 100644 (file)
@@ -149,6 +149,8 @@ private:
        float __anchorPopupOverlap;
 
        bool __enterKeyPressed;
+       bool __backKeyPressed;
+       int __focusedIndex;
 }; // _ContextMenuListPresenter
 
 }}} // Tizen::Ui: Control