From 8834a0ffc0be61218ab86bf209cb6cd53a18a565 Mon Sep 17 00:00:00 2001 From: that Date: Tue, 5 Jan 2016 23:29:30 +0100 Subject: gui: add keyboard support for Ctrl layer and more special keys - rename NotifyKeyboard to NotifyCharInput - input: handle arrow keys in NotifyKey with standard KEY_* codes - fix page handler to return 0 from NotifyKey if key was handled - fix GUIAction::NotifyKey to not swallow all keys - change home button code from KEY_HOME to KEY_HOMEPAGE (to avoid collision with Home/End, conforms to Android 3.0+) Change-Id: Ib138afa492df8d0c1975415e8b5334c8778ccc90 --- gui/pages.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'gui/pages.cpp') diff --git a/gui/pages.cpp b/gui/pages.cpp index 4a65c69e4..c097c39bd 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -584,15 +584,13 @@ int Page::NotifyKey(int key, bool down) { std::vector::reverse_iterator iter; - // Don't try to handle a lack of handlers - 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++) { ret = (*iter)->NotifyKey(key, down); + if (ret == 0) + return 0; if (ret < 0) { LOGERR("An action handler has returned an error\n"); ret = 1; @@ -601,22 +599,18 @@ int Page::NotifyKey(int key, bool down) return ret; } -int Page::NotifyKeyboard(int key) +int Page::NotifyCharInput(int ch) { std::vector::reverse_iterator iter; - // Don't try to handle a lack of handlers - if (mInputs.size() == 0) - return 1; - // We work backwards, from top-most element to bottom-most element for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++) { - int ret = (*iter)->NotifyKeyboard(key); + int ret = (*iter)->NotifyCharInput(ch); if (ret == 0) return 0; else if (ret < 0) - LOGERR("A keyboard handler has returned an error"); + LOGERR("A char input handler has returned an error"); } return 1; } @@ -625,10 +619,6 @@ int Page::SetKeyBoardFocus(int inFocus) { std::vector::reverse_iterator iter; - // Don't try to handle a lack of handlers - if (mInputs.size() == 0) - return 1; - // We work backwards, from top-most element to bottom-most element for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++) { @@ -1155,12 +1145,12 @@ int PageSet::NotifyKey(int key, bool down) return (mCurrentPage ? mCurrentPage->NotifyKey(key, down) : -1); } -int PageSet::NotifyKeyboard(int key) +int PageSet::NotifyCharInput(int ch) { if (!mOverlays.empty()) - return mOverlays.back()->NotifyKeyboard(key); + return mOverlays.back()->NotifyCharInput(ch); - return (mCurrentPage ? mCurrentPage->NotifyKeyboard(key) : -1); + return (mCurrentPage ? mCurrentPage->NotifyCharInput(ch) : -1); } int PageSet::SetKeyBoardFocus(int inFocus) @@ -1654,9 +1644,9 @@ int PageManager::NotifyKey(int key, bool down) return (mCurrentSet ? mCurrentSet->NotifyKey(key, down) : -1); } -int PageManager::NotifyKeyboard(int key) +int PageManager::NotifyCharInput(int ch) { - return (mCurrentSet ? mCurrentSet->NotifyKeyboard(key) : -1); + return (mCurrentSet ? mCurrentSet->NotifyCharInput(ch) : -1); } int PageManager::SetKeyBoardFocus(int inFocus) -- cgit v1.2.3