Page 1 of 1

Using Listboxes

Posted: Thu May 19, 2005 11:57
by zander1976
Hello Everybody,

I did some searching threw the forum and I can't really find anything that is helping me. I have also looked threw the api ref and I am not sure what the best way to use listboxes.

I am creating the listbox item with and id:

Code: Select all

CEGUI::ListboxTextItem *listboxitem = new CEGUI::ListboxTextItem( text, id );

List->addItem(listboxitem);


That works great, now what I am having problems with is deleting the item. Is there anyway to delete based on the id. Something like:

Code: Select all

List->deleteItem( id );


Also do I have to delete the item myself

Code: Select all

CEGUI::ListboxTextItem *item = List->getItem( id );
delete item;
item = ;
List->deleteItem( id );


Ohh, one last question when I select an item can i get it to return the key I gave it or just the text.

Thanks, Ben

Re: Using Listboxes

Posted: Thu May 19, 2005 15:07
by zander1976
Hello,

I figured it out (well sort of anyway). Here is what I ended up doing. Its deleting based on text now.

Code: Select all

CEGUI::ListboxItem *listboxitem = mPlayerList->findItemWithText( name, mPlayerList->getListboxItemFromIndex(0) );
mPlayerList->removeItem( listboxitem );


Let me know if this is a bad idea

Ben