From b262fd7f9665736ad45ad65b0123bf5e0d2bb273 Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 20 Apr 2009 19:34:40 +0000 Subject: [PATCH] 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 --- src/gui/screen.cpp | 25 +++++++++++++++++++++++++ src/gui/widget.cpp | 7 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/gui/screen.cpp b/src/gui/screen.cpp index 9eb790f8e..7d45fd9be 100644 --- a/src/gui/screen.cpp +++ b/src/gui/screen.cpp @@ -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(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(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)) { diff --git a/src/gui/widget.cpp b/src/gui/widget.cpp index a934ce646..44ab9a8f3 100644 --- a/src/gui/widget.cpp +++ b/src/gui/widget.cpp @@ -1167,11 +1167,16 @@ void ListWidget::add() { rect widget_size = rect(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); }