Fixed keyboard navigation bug when a dialog was shown

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4341 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-22 20:54:43 +00:00
parent 6127b2b4b3
commit 93e569c3a2
3 changed files with 50 additions and 3 deletions

View File

@ -381,6 +381,11 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b
}
}
// don't allow navigating to any widget when a dialog is shown; only navigate to widgets in the dialog
if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyChild(el))
{
el = NULL;
}
// find closest widget
if (el != NULL && el->getTabGroup() != NULL &&
@ -413,7 +418,7 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b
if (ModalDialog::isADialogActive())
{
// TODO : select last widget in modal dialogs
w = ModalDialog::getCurrent()->getLastWidget();
}
else
{
@ -487,6 +492,11 @@ void EventHandler::navigateDown(const int playerID, Input::InputType type, const
}
}
// don't allow navigating to any widget when a dialog is shown; only navigate to widgets in the dialog
if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyChild(el))
{
el = NULL;
}
if (el != NULL && el->getTabGroup() != NULL &&
el->getTabGroup()->getNextElement(el->getTabOrder(), false, false, first, closest))
@ -521,7 +531,8 @@ void EventHandler::navigateDown(const int playerID, Input::InputType type, const
if (ModalDialog::isADialogActive())
{
// TODO : select first widget in modal dialogs
std::cout << "w = ModalDialog::getCurrent()->getFirstWidget();\n";
w = ModalDialog::getCurrent()->getFirstWidget();
}
else
{

View File

@ -115,4 +115,36 @@ void ModalDialog::onEnterPressedInternal()
{
}
Widget* ModalDialog::getLastWidget()
{
const int childrenCount = m_children.size();
for (int i=childrenCount-1; i>=0; i--)
{
if (m_children[i].getIrrlichtElement() == NULL || m_children[i].getIrrlichtElement()->getTabOrder() == -1 ||
m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */)
{
continue;
}
return m_children.get(i);
}
return NULL;
}
Widget* ModalDialog::getFirstWidget()
{
const int childrenCount = m_children.size();
for (int i=0; i<childrenCount; i++)
{
if (m_children[i].getIrrlichtElement() == NULL || m_children[i].getIrrlichtElement()->getTabOrder() == -1 ||
m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */)
{
continue;
}
return m_children.get(i);
}
return NULL;
}
}

View File

@ -60,7 +60,11 @@ public:
virtual EventPropagation processEvent(std::string& eventSource){ return EVENT_LET; }
bool isMyChild(Widget* widget) const { return m_children.contains(widget); }
bool isMyChild(irr::gui::IGUIElement* widget) const { return m_irrlicht_window->isMyChild(widget); }
Widget* getFirstWidget();
Widget* getLastWidget();
irr::gui::IGUIWindow* getIrrlichtElement()
{
return m_irrlicht_window;