Page 1 of 1

listbox's event

Posted: Mon Jan 16, 2006 11:06
by pabloa
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"

Re: listbox's event

Posted: Mon Jan 16, 2006 14:45
by lindquist
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

Re: listbox's event

Posted: Mon Jan 16, 2006 16:31
by pabloa
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"

Re: listbox's event

Posted: Tue Jan 17, 2006 10:26
by pabloa
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(){..