made player list navigatable without mouse

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3415 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-20 19:34:40 +00:00
parent 0ee65fc802
commit b262fd7f96
2 changed files with 31 additions and 1 deletions

View File

@ -407,6 +407,19 @@ bool Screen::OnEvent(const SEvent& event)
{
IGUIElement *el, *first=NULL, *closest=NULL;
el = GUIEngine::getGUIEnv()->getFocus();
Widget* w = getWidget( el->getID() );
// list widgets are a bit special, because up/down keys are also used
// to navigate between various list items, not only to navigate between
// components
if(w->m_type == WTYPE_LIST)
{
IGUIListBox* list = dynamic_cast<IGUIListBox*>(w->m_element);
assert(list != NULL);
if(list->getSelected()>0) break;
}
if(el != NULL && el->getTabGroup() != NULL &&
el->getTabGroup()->getNextElement(el->getTabOrder(), true, false, first, closest))
{
@ -426,6 +439,18 @@ bool Screen::OnEvent(const SEvent& event)
IGUIElement *el, *first = NULL, *closest = NULL;
el = GUIEngine::getGUIEnv()->getFocus();
Widget* w = getWidget( el->getID() );
// list widgets are a bit special, because up/down keys are also used
// to navigate between various list items, not only to navigate between
// components
if(w->m_type == WTYPE_LIST)
{
IGUIListBox* list = dynamic_cast<IGUIListBox*>(w->m_element);
assert(list != NULL);
if(list->getSelected() < (int)list->getItemCount()-1) break;
}
if(el != NULL && el->getTabGroup() != NULL &&
el->getTabGroup()->getNextElement(el->getTabOrder(), false, false, first, closest))
{

View File

@ -1167,11 +1167,16 @@ void ListWidget::add()
{
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
IGUIListBox* list = GUIEngine::getGUIEnv()->addListBox (widget_size);
IGUIListBox* list = GUIEngine::getGUIEnv()->addListBox (widget_size, NULL, ++id_counter);
id = list->getID();
list->addItem( L"Hiker" );
list->addItem( L"Conso" );
list->addItem( L"Auria" );
list->addItem( L"MiniBjorn" );
list->addItem( L"Arthur" );
m_element = list;
//list->setSelected(0);
}