Page 1 of 1

Listbox event question

Posted: Sat Mar 17, 2007 4:39 am
by khamill
Hi Guys,

I have a listbox event coming in. I'm getting separate events for separate listboxes. All is good.

Question:

How do I tell which item in the listbox has been selected? For example, If I have a listbox with "Yes" and "No" items and I select "Yes" to get the event, How do I know this event is for the "Yes" selection. Is there a field in the event coming in with an item # or text value?

I've checked the docs and it doesn't appear obvious unless I'm not seeing it which is entirely possible (likely).

thanks

Kevin

Posted: Sat Mar 17, 2007 5:25 am
by vitek
The event.GUIEvent.Caller can be a pointer to the IGUIElement that generated the message. You can use use getID() to get the ID of the element. If necessary, you can cast the Caller to the appropriate element type so you can call functions on it. If event.GUIEvent.EventType is gui::EGET_LISTBOX_CHANGED you should be able to cast the Caller pointer to an IGUIListBox.

Travis

Posted: Sat Mar 17, 2007 2:19 pm
by Acki
right, and with getSelected() you can check witch listbox item is selected...

Posted: Sat Mar 17, 2007 5:11 pm
by khamill
Thanks

getSelected() did the trick!!

Kevin