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:
parent
6127b2b4b3
commit
93e569c3a2
@ -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
|
// find closest widget
|
||||||
if (el != NULL && el->getTabGroup() != NULL &&
|
if (el != NULL && el->getTabGroup() != NULL &&
|
||||||
@ -413,7 +418,7 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b
|
|||||||
|
|
||||||
if (ModalDialog::isADialogActive())
|
if (ModalDialog::isADialogActive())
|
||||||
{
|
{
|
||||||
// TODO : select last widget in modal dialogs
|
w = ModalDialog::getCurrent()->getLastWidget();
|
||||||
}
|
}
|
||||||
else
|
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 &&
|
if (el != NULL && el->getTabGroup() != NULL &&
|
||||||
el->getTabGroup()->getNextElement(el->getTabOrder(), false, false, first, closest))
|
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())
|
if (ModalDialog::isADialogActive())
|
||||||
{
|
{
|
||||||
// TODO : select first widget in modal dialogs
|
std::cout << "w = ModalDialog::getCurrent()->getFirstWidget();\n";
|
||||||
|
w = ModalDialog::getCurrent()->getFirstWidget();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,11 @@ public:
|
|||||||
virtual EventPropagation processEvent(std::string& eventSource){ return EVENT_LET; }
|
virtual EventPropagation processEvent(std::string& eventSource){ return EVENT_LET; }
|
||||||
|
|
||||||
bool isMyChild(Widget* widget) const { return m_children.contains(widget); }
|
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()
|
irr::gui::IGUIWindow* getIrrlichtElement()
|
||||||
{
|
{
|
||||||
return m_irrlicht_window;
|
return m_irrlicht_window;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user