[Solved]Listbox: get text from certain element
Posted: Wed May 10, 2006 2:54 pm
Hi!
I got a little problem concerning listboxes:
We are working on a game project and I'm responsible for the Menus and Gui.
I'm currently working on the graphics-menu: I made a listbox and added 4 standard-resolutions to it ( with addItem()). It perfectly works.
Now I want to give the user the possibility to select one of the resolutions, click on the apply button and voila: resolution changes!
Now here is my problem: I wanted to get the text from the selected item:
It seems logically for me to do it this way, no compile errors appear. However, if I start the program, an error appears.
It seems, that if i select something other than the Element(0) the game hangs up. And the text of the Element(0) is an empty string, but is correctly displayed in the listbox.
Strangly all other elements seem to have correctly assigned id's, I just cannot access them without an error...
Can anybody help me?
Regards
Lo_Ord
I got a little problem concerning listboxes:
We are working on a game project and I'm responsible for the Menus and Gui.
I'm currently working on the graphics-menu: I made a listbox and added 4 standard-resolutions to it ( with addItem()). It perfectly works.
Now I want to give the user the possibility to select one of the resolutions, click on the apply button and voila: resolution changes!
Now here is my problem: I wanted to get the text from the selected item:
Code: Select all
IGUIListBox *box;
s32 selected;
const wchar_t str;
//added items to the box
//now i'm trying to get the string of the selected resolution:
if ((selected = box->getSelected()) != -1=
{
str = box->getElementFromId(selected)->getText();
}
//change resolution
It seems, that if i select something other than the Element(0) the game hangs up. And the text of the Element(0) is an empty string, but is correctly displayed in the listbox.
Strangly all other elements seem to have correctly assigned id's, I just cannot access them without an error...
Can anybody help me?
Regards
Lo_Ord