Skip to main content
Participating Frequently
March 24, 2010
Answered

event listener on dropdown list item

  • March 24, 2010
  • 1 reply
  • 812 views

Hello,

I'd like to display tool tips, once the user holds his mouse on an item of an opened combobox.

Ifyou open the drop down list of a combo box, you'll see a list ofelements/items. Each of them can be accessed e.g. viamyCombo.getItemAt(0) .

To me it seems I only get an object with adata and label property. But I think there must be more to it, becausewhen you hold your mouse over a sub-element, it'll be highlighted. Thismeans that there is some event listener on that very single item. Sohow can I do this?

myCombo.getItemAt(0).addEventListener(MouseEvent.MOUSE_OVER, ShowToolTip); //impossible


function ShowToolTip(evt)
{
  trace(evt.currentTarget.label);//stub action
}

Thanks in advance.

Gilzad

This topic has been closed for replies.
Correct answer Ned Murphy

If you look up the component in the help documents you can find all of the events that are associated with that object.  If your drop list is a ComboBox component, it has events such as what you appear to want to have, itemRollOver and itemRollOut, along with an example using them.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 24, 2010

If you look up the component in the help documents you can find all of the events that are associated with that object.  If your drop list is a ComboBox component, it has events such as what you appear to want to have, itemRollOver and itemRollOut, along with an example using them.

gilzadAuthor
Participating Frequently
March 25, 2010

Perfect.

I didn't think of the proper object to look for its events. itemRollOver and itemRollOut were the perfect keywords to find a useful example in the help documents.

Thanks Ned Murphy.

For anyone who might come across this:

import fl.events.ListEvent;

myComboBox.dropdown.addEventListener(ListEvent.ITEM_ROLL_OVER, ItemEventHandler);

function ItemEventHandler(evt:ListEvent)

{

  trace(evt.currentTarget.getItemAt(evt.rowIndex).label);//prints label of hovered list item.

}

Ned Murphy
Legend
March 25, 2010

You're welcome.  You don't need to know the keywrords to search on.  If you look up the Class any object all of the properties, methods, and events associated with it are dealt with in one page, including examples for many.