Ejemplo n.º 1
0
bool UINode::addFirstFocus ()
{
	bool focus = false;
	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		nodePtr->removeFocus();
		if (focus)
			continue;
		focus = nodePtr->addFirstFocus();
		if (focus)
			addFocus(0, 0);
	}

	if (_nodes.empty() && isActive()) {
		addFocus(0, 0);
		return true;
	}
	return focus;
}
Ejemplo n.º 2
0
bool UINode::nextFocus ()
{
	if (_nodes.empty()) {
		if (!isActive())
			return false;
		if (hasFocus())
			return false;
		addFocus(0, 0);
		return true;
	}

	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		// search the node that currently has the focus
		if (!nodePtr->hasFocus())
			continue;

		if (nodePtr->nextFocus()) {
			addFocus(0, 0);
			return true;
		}

		nodePtr->removeFocus();
		for (++i; i != _nodes.end(); ++i) {
			UINode* focusNodePtr = *i;
			if (focusNodePtr->addFirstFocus()) {
				addFocus(0, 0);
				return true;
			}
		}
		break;
	}

	removeFocus();

	return false;
}