From 4620ebba765f9bb7fd73a44bfacb6bc241c6314e Mon Sep 17 00:00:00 2001 From: Gwangbok Kim Date: Fri, 28 Jun 2013 18:05:10 +0900 Subject: [PATCH] add code for closing popup with esc and back key Change-Id: I182e777c3446d8484b1ff105c134c0cc3a24a583 Signed-off-by: Gwangbok Kim --- project/inc/AddressbookListPopup.h | 6 ++++++ project/src/AddressbookListPopup.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/project/inc/AddressbookListPopup.h b/project/inc/AddressbookListPopup.h index a438312..71a2113 100644 --- a/project/inc/AddressbookListPopup.h +++ b/project/inc/AddressbookListPopup.h @@ -23,6 +23,7 @@ class AddressbookListPopup : public Tizen::Ui::Controls::Popup , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::IPropagatedKeyEventListener , public Tizen::Ui::Controls::IListViewItemEventListener , public Tizen::Ui::Controls::IListViewItemProvider { @@ -48,6 +49,11 @@ public: virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); virtual int GetItemCount(void); + virtual bool OnKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo); + virtual bool OnKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo); + virtual bool OnPreviewKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo); + virtual bool OnPreviewKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo); + result Construct(const Tizen::Ui::Controls::Form* pForm); result GetAddressbookList(void); diff --git a/project/src/AddressbookListPopup.cpp b/project/src/AddressbookListPopup.cpp index b2a10ed..bdcd649 100644 --- a/project/src/AddressbookListPopup.cpp +++ b/project/src/AddressbookListPopup.cpp @@ -76,6 +76,8 @@ AddressbookListPopup::Construct(const Form* pForm) __pListView->AddListViewItemEventListener(*this); pPopupScrollPanel->AddControl(__pListView); + SetPropagatedKeyEventListener(this); + r = GetAddressbookList(); TryReturn(!IsFailed(r), r, "Failed to get addressbook list (%s)", GetErrorMessage(r)); @@ -168,6 +170,35 @@ AddressbookListPopup::OnItemReordered(Tizen::Ui::Controls::ListView& view, int o { } +bool +AddressbookListPopup::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo) +{ + return true; +} + +bool +AddressbookListPopup::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo) +{ + if (keyEventInfo.GetKeyCode() == KEY_ESC || keyEventInfo.GetKeyCode() == KEY_BACK) + { + __pForm->SendUserEvent(0, null); + } + + return true; +} + +bool +AddressbookListPopup::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo) +{ + return true; +} + +bool +AddressbookListPopup::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo) +{ + return true; +} + Tizen::Ui::Controls::ListItemBase* AddressbookListPopup::CreateItem(int index, int itemWidth) { -- 2.7.4