listbox's event

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

listbox's event

Postby pabloa » Mon Jan 16, 2006 11:06

I had been searching it in forum and wiki but I cant find it. I would like do diferent thing depend the item select, then I associate a event to the Listbox (which will be the correct?) I have now EventMouseButtonDown, then in my HandleListbox I have this, dont work so it is not the right code:

Code: Select all

if (itemp1->isSelected()){
      pos1->setText("One thing");}
   else if  (itemp2->isSelected()){
      pos1->setText("another thing");}

pos1 is a editbox and itemp1 & itemp2 are items from listbox.

Always show me in the editbox "One thing"

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

Re: listbox's event

Postby lindquist » Mon Jan 16, 2006 14:45

You probably want to do this by handling the Listbox::EventSelectionChanged.

You can then use the methods Listbox::getFirstSelectedItem to get a pointer to the first selected listbox item in you listbox.

HTH

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: listbox's event

Postby pabloa » Mon Jan 16, 2006 16:31

the method Listbox::getFirstSelectedItem return a ListboxItem pointer. The problem is what I have in my listbox are ListboxTextItem

Code: Select all

   if (posiciones->getFirstSelectedItem()== itemp1)
   {
      pos1->setText("A");
   }else{
      pos1->setText("B");
   }
 


print me always "B"

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: listbox's event

Postby pabloa » Tue Jan 17, 2006 10:26

I solved it (with the help of scriptkid). it is

Code: Select all

if (posiciones->getFirstSelectedItem()->getText()== "Point a"){...

or

Code: Select all

if (posiciones->getFirstSelectedItem()->isSelected(){..


Return to “Help”

Who is online

Users browsing this forum: No registered users and 16 guests