Listbox trouble

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
wingdongdoodle
Just popping in
Just popping in
Posts: 15
Joined: Tue Mar 15, 2005 21:41

Listbox trouble

Postby wingdongdoodle » Sat Jul 16, 2005 08:04

I hate to sound like a moron here, but i have been unable to figure out how to allow someone to actually select an item in a list box.

i have this code to actually interface with teh list (non-multi select)

Code: Select all

   std::string objName;
   CEGUI::ListboxItem *t;
   t=objectsList->getFirstSelectedItem();
   if(!t)
      return false;
   
   objName=t->getText().c_str();
   currentBody=mPhysicsWorld->getBody(objName);
   update();


inside a buttonPRess event.

im assuming, since i cant seem to select an item, that there must be an event i have to subscribe to in order to select an item. I figure thats mouse click, but from there, how do i tell which item has actually been clicked in the list in order to select it?

arg!

thanks for the help in advance...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Listbox trouble

Postby CrazyEddie » Sat Jul 16, 2005 08:23

The event you need to listen to for this is:

Code: Select all

Listbox::EventSelectionChanged


Don't forget that to get visual feedback on the selected item(s) you need to set the selection brush and optionally selection colours on each item that you add to the list.

User avatar
wingdongdoodle
Just popping in
Just popping in
Posts: 15
Joined: Tue Mar 15, 2005 21:41

Re: Listbox trouble

Postby wingdongdoodle » Sat Jul 16, 2005 09:06

thanks, Iva managed to successfully allow selection in the list, however, i still cant manage to get a selection color to show up. I changed each ListboxItem->selectionColour() to a new color (200,0,0)RGB to try to make it show up...but no use. Is the settign of colors something i have to do inside the eventHandler function?

if it helps,

Code: Select all

CEGUI::ListboxItem *item=new CEGUI::ListboxTextItem(objects[a]);
item->isAutoDeleted();
CEGUI::colour col(200,10,10,0);
item->setSelectionColours(col);
objectsList->addItem(item);


and the eventhandler is empty.

i shall continue to fiddle

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Listbox trouble

Postby lindquist » Sat Jul 16, 2005 10:15

you need to set the selection brush. that is an image!

Code: Select all

ListboxItem::setSelectionBrushImage

User avatar
wingdongdoodle
Just popping in
Just popping in
Posts: 15
Joined: Tue Mar 15, 2005 21:41

Re: Listbox trouble

Postby wingdongdoodle » Sat Jul 16, 2005 11:28

>sigh<

ok, i was under the impression that you coudl simply pick a selection color and not worry about the selectionBrushImage.

bah.

ill mess with this sometime later, thanks for the help though,.

[edit]

well, i chose a selection brush for each ListBoxItem, but they still refuse to be highlighted when selected. I even followed example code from one of the demos. Listboxes apparently are the bane of my existance or something.

here is how i add a listboxitem to the lsitbox

Code: Select all

CEGUI::ListboxItem *item=new CEGUI::ListboxTextItem(objects[a]);
item->isAutoDeleted();
         item->setSelectionBrushImage((CEGUI::utf8*)"TaharezLook",
    (CEGUI::utf8*)"ListboxSelectionBrush");
objectsList->addItem(item);


the TaharezScheme is loaded (its the only one im using).
and the list box DOES select items, just still does not highlight the selected item.

i dont kno what to do here, i have tried everythign i could think of

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Listbox trouble

Postby lindquist » Sun Jul 17, 2005 18:31

The ListboxSelectionBrush image in the TaharezLook file is just plain white, so I think you need to choose a colour for it aswell, or modify the image.

User avatar
wingdongdoodle
Just popping in
Just popping in
Posts: 15
Joined: Tue Mar 15, 2005 21:41

Re: Listbox trouble

Postby wingdongdoodle » Sun Jul 17, 2005 19:27

Yeah, i thought i would need to set a color as well, but i set the selection color, and im still not getting any highlighting in my listbox.

anyone have any simple sample code of what they had done?

arrr, these listboxes are quite frustrating

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Listbox trouble

Postby CrazyEddie » Mon Jul 18, 2005 08:17

How are you setting the colour? Do not forget that the alpha component of the colour is significant.

I always recommend that people create their own little sub-class of ListboxTextItem that does all the initialisation for them. This makes your code much cleaner.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 25 guests