Attempt to fix tab traversal in irrlicht 1.8

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8079 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-03-27 00:53:28 +00:00
parent 7377d6739e
commit 1985d54536

View File

@ -236,7 +236,7 @@ const bool NAVIGATION_DEBUG = false;
void EventHandler::navigateUp(const int playerID, Input::InputType type, const bool pressedDown)
{
//std::cout << "Naviagte up!\n";
IGUIElement *el = NULL, *first=NULL, *closest=NULL;
IGUIElement *el = NULL/*, *first=NULL*/, *closest=NULL;
if (type == Input::IT_STICKBUTTON && !pressedDown)
return;
@ -294,13 +294,11 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b
if (el != NULL && el->getTabGroup() != NULL)
{
// if the current widget is e.g. 15, search for widget 14, 13, 12, ... (up to 10 IDs may be missing)
for (int n=0; n<10 && !found; n++)
for (int n=1; n<10 && !found; n++)
{
const bool success = el->getTabGroup()->getNextElement(el->getTabOrder() - n,
true /* reverse */, false /* group */,
first, closest, true);
closest = GUIEngine::getGUIEnv()->getRootGUIElement()->getElementFromId(el->getTabOrder() - n, true);
if (success)
if (closest != NULL && Widget::isFocusableId(closest->getID()))
{
if (NAVIGATION_DEBUG) std::cout << "Navigating up to " << closest->getID() << std::endl;
Widget* closestWidget = GUIEngine::getWidget( closest->getID() );
@ -330,19 +328,6 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b
if (NAVIGATION_DEBUG)
{
std::cout << "EventHandler::navigateUp : warp around, selecting the last widget\n";
if (el == NULL)
{
std::cout << " because el is null\n";
}
else if (el->getTabGroup() == NULL)
{
std::cout << " because el's tab group is null\n";
}
else if (!el->getTabGroup()->getNextElement(el->getTabOrder(), true, false, first, closest))
{
std::cout << " because el (" << core::stringc(el->getText()).c_str() << ", tab order "
<< el->getTabOrder() << ") has no known previous\n";
}
}
// select the last widget
@ -369,7 +354,7 @@ void EventHandler::navigateDown(const int playerID, Input::InputType type, const
{
//std::cout << "Naviagte down!\n";
IGUIElement *el = NULL, *first = NULL, *closest = NULL;
IGUIElement *el = NULL, *closest = NULL;
if (type == Input::IT_STICKBUTTON && !pressedDown)
return;
@ -425,11 +410,11 @@ void EventHandler::navigateDown(const int playerID, Input::InputType type, const
if (el != NULL && el->getTabGroup() != NULL)
{
// if the current widget is e.g. 5, search for widget 6, 7, 8, 9, ..., 15 (up to 10 IDs may be missing)
for (int n=0; n<10 && !found; n++)
for (int n=1; n<10 && !found; n++)
{
const bool success = el->getTabGroup()->getNextElement(el->getTabOrder() + n,
false, false, first, closest, true);
if (success && closest->getID() != -1)
closest = GUIEngine::getGUIEnv()->getRootGUIElement()->getElementFromId(el->getTabOrder() + n, true);
if (closest != NULL && Widget::isFocusableId(closest->getID()))
{
Widget* closestWidget = GUIEngine::getWidget( closest->getID() );
if (playerID != PLAYER_ID_GAME_MASTER && !closestWidget->m_supports_multiplayer) return;