From 0b7fe504dc93246957aee38c0d93ea1fa1580fab Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Thu, 13 Mar 2014 17:36:52 +0100 Subject: Add support for actions triggered by key combination Change-Id: I9dfa7de40229f00412d63fc9c1eb3a809a6eb2e6 Signed-off-by: Vojtech Bocek --- gui/pages.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'gui/pages.cpp') diff --git a/gui/pages.cpp b/gui/pages.cpp index 2953eddb8..398224e17 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -55,6 +55,7 @@ std::map PageManager::mPageSets; PageSet* PageManager::mCurrentSet; PageSet* PageManager::mBaseSet = NULL; MouseCursor *PageManager::mMouseCursor = NULL; +HardwareKeyboard *PageManager::mHardwareKeyboard = NULL; // Helper routine to convert a string to a color declaration int ConvertStrToColor(std::string str, COLOR* color) @@ -447,7 +448,7 @@ int Page::NotifyTouch(TOUCH_STATE state, int x, int y) return ret; } -int Page::NotifyKey(int key) +int Page::NotifyKey(int key, bool down) { std::vector::reverse_iterator iter; @@ -455,16 +456,17 @@ int Page::NotifyKey(int key) if (mActions.size() == 0) return 1; + int ret = 1; // We work backwards, from top-most element to bottom-most element for (iter = mActions.rbegin(); iter != mActions.rend(); iter++) { - int ret = (*iter)->NotifyKey(key); - if (ret == 0) - return 0; - else if (ret < 0) - LOGERR("An action handler has returned an error"); + ret = (*iter)->NotifyKey(key, down); + if (ret < 0) { + LOGERR("An action handler has returned an error\n"); + ret = 1; + } } - return 1; + return ret; } int Page::NotifyKeyboard(int key) @@ -719,12 +721,12 @@ int PageSet::NotifyTouch(TOUCH_STATE state, int x, int y) return (mCurrentPage ? mCurrentPage->NotifyTouch(state, x, y) : -1); } -int PageSet::NotifyKey(int key) +int PageSet::NotifyKey(int key, bool down) { if (mOverlayPage) - return (mOverlayPage->NotifyKey(key)); + return (mOverlayPage->NotifyKey(key, down)); - return (mCurrentPage ? mCurrentPage->NotifyKey(key) : -1); + return (mCurrentPage ? mCurrentPage->NotifyKey(key, down) : -1); } int PageSet::NotifyKeyboard(int key) @@ -964,6 +966,13 @@ int PageManager::Render(void) return res; } +HardwareKeyboard *PageManager::GetHardwareKeyboard() +{ + if(!mHardwareKeyboard) + mHardwareKeyboard = new HardwareKeyboard(); + return mHardwareKeyboard; +} + MouseCursor *PageManager::GetMouseCursor() { if(!mMouseCursor) @@ -1002,9 +1011,9 @@ int PageManager::NotifyTouch(TOUCH_STATE state, int x, int y) return (mCurrentSet ? mCurrentSet->NotifyTouch(state, x, y) : -1); } -int PageManager::NotifyKey(int key) +int PageManager::NotifyKey(int key, bool down) { - return (mCurrentSet ? mCurrentSet->NotifyKey(key) : -1); + return (mCurrentSet ? mCurrentSet->NotifyKey(key, down) : -1); } int PageManager::NotifyKeyboard(int key) -- cgit v1.2.3