|
|
@@ -635,6 +635,8 @@ bool Container::keyEvent(Keyboard::KeyEvent evt, int key)
|
|
|
// need to keep it alive until the method returns.
|
|
|
addRef();
|
|
|
|
|
|
+ bool eventConsumed = false;
|
|
|
+
|
|
|
std::vector<Control*>::const_iterator it;
|
|
|
for (it = _controls.begin(); it < _controls.end(); it++)
|
|
|
{
|
|
|
@@ -645,22 +647,81 @@ bool Container::keyEvent(Keyboard::KeyEvent evt, int key)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (control->hasFocus() && control->keyEvent(evt, key))
|
|
|
+ if ((control->hasFocus() || control->getState() == ACTIVE) && control->keyEvent(evt, key))
|
|
|
{
|
|
|
- release();
|
|
|
- return true;
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // If we made it this far, no control handled the event.
|
|
|
- if (evt == Keyboard::KEY_CHAR && key == Keyboard::KEY_TAB)
|
|
|
+ switch (evt)
|
|
|
{
|
|
|
- moveFocus(NEXT);
|
|
|
- return _consumeInputEvents;
|
|
|
+ case Keyboard::KEY_PRESS:
|
|
|
+ {
|
|
|
+ if (!eventConsumed)
|
|
|
+ {
|
|
|
+ switch (key)
|
|
|
+ {
|
|
|
+ case Keyboard::KEY_TAB:
|
|
|
+ _focusPressed |= NEXT;
|
|
|
+ if (moveFocus(NEXT))
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_UP_ARROW:
|
|
|
+ _focusPressed |= UP;
|
|
|
+ if (moveFocus(UP))
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_DOWN_ARROW:
|
|
|
+ _focusPressed |= DOWN;
|
|
|
+ if (moveFocus(DOWN))
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_LEFT_ARROW:
|
|
|
+ _focusPressed |= LEFT;
|
|
|
+ if (moveFocus(LEFT))
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_RIGHT_ARROW:
|
|
|
+ _focusPressed |= RIGHT;
|
|
|
+ if (moveFocus(RIGHT))
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case Keyboard::KEY_RELEASE:
|
|
|
+ {
|
|
|
+ switch (key)
|
|
|
+ {
|
|
|
+ case Keyboard::KEY_TAB:
|
|
|
+ _focusPressed &= ~NEXT;
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_UP_ARROW:
|
|
|
+ _focusPressed &= ~UP;
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_DOWN_ARROW:
|
|
|
+ _focusPressed &= ~DOWN;
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_LEFT_ARROW:
|
|
|
+ _focusPressed &= ~LEFT;
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ case Keyboard::KEY_RIGHT_ARROW:
|
|
|
+ _focusPressed &= ~RIGHT;
|
|
|
+ eventConsumed |= true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
release();
|
|
|
- return false;
|
|
|
+ return eventConsumed;
|
|
|
}
|
|
|
|
|
|
void Container::guaranteeFocus(Control* inFocus)
|
|
|
@@ -787,10 +848,11 @@ bool Container::moveFocus(Direction direction, Control* outsideControl)
|
|
|
if (!next)
|
|
|
{
|
|
|
// Check for controls in the given direction in our parent container.
|
|
|
- if (!outsideControl && _parent && _parent->moveFocus(direction, start))
|
|
|
+ if (direction != NEXT && !outsideControl && _parent && _parent->moveFocus(direction, start))
|
|
|
{
|
|
|
setState(NORMAL);
|
|
|
_focusChangeRepeat = false;
|
|
|
+ _focusPressed = 0;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -821,6 +883,14 @@ bool Container::moveFocus(Direction direction, Control* outsideControl)
|
|
|
|
|
|
if (focusIndex > _focusIndexMax)
|
|
|
{
|
|
|
+ if (direction == NEXT && !outsideControl && _parent && _parent->moveFocus(direction, start))
|
|
|
+ {
|
|
|
+ setState(NORMAL);
|
|
|
+ _focusChangeRepeat = false;
|
|
|
+ _focusPressed = 0;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
focusIndex = 0;
|
|
|
}
|
|
|
else if (focusIndex < 0)
|
|
|
@@ -839,6 +909,7 @@ bool Container::moveFocus(Direction direction, Control* outsideControl)
|
|
|
if (nextControl->getFocusIndex() == focusIndex)
|
|
|
{
|
|
|
next = nextControl;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -851,9 +922,11 @@ bool Container::moveFocus(Direction direction, Control* outsideControl)
|
|
|
|
|
|
if (next->isContainer())
|
|
|
{
|
|
|
- if (((Container*)next)->moveFocus(direction, start))
|
|
|
+ if ((direction == NEXT && ((Container*)next)->moveFocus(direction)) ||
|
|
|
+ ((Container*)next)->moveFocus(direction, start))
|
|
|
{
|
|
|
_focusChangeRepeat = false;
|
|
|
+ _focusPressed = 0;
|
|
|
return true;
|
|
|
}
|
|
|
}
|