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
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 4a65c69..c097c39 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -584,15 +584,13 @@
{
std::vector<ActionObject*>::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 @@
return ret;
}
-int Page::NotifyKeyboard(int key)
+int Page::NotifyCharInput(int ch)
{
std::vector<InputObject*>::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 @@
{
std::vector<InputObject*>::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 @@
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 @@
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)