Reputation: 12552
I'm working with a custom List component in flex4. I've created a custom ItemRenderer and everything looks and works as i want, but i'm trying to get the double click event. I'm receiving key down and all other events, but not this one. I've enabled the double click on the List component
doubleClickEnabled="true"
and i've added an event listener for
ListEvent.ITEM_DOUBLE_CLICK
I can click as long as i want, the event just is not triggered. I could use any advice. Thanks.
Upvotes: 2
Views: 6121
Reputation: 809
I banged my head on the wall for hours because of this ! Adobe is going backwards with component functionality ! anyway, I found a decent solution :
We're going to add the DOUBLE_CLICK event listener to the dataGroup of the list, which is the container of the items :
list.dataGroup.doubleClickEnabled = true;
list.dataGroup.addEventListener(MouseEvent.DOUBLE_CLICK, handleDoubleClick);
Now it works nice, not provoking a double click from the scroller, but sill provoking a double click from an open space (the dataGroup itself) in the list where there are no items. so we only continue the event handler if e.target != dataGroup :
private function handleDoubleClick(e:MouseEvent):void
{
if (list.dataGroup != e.target)
{
// double click code
}
}
Now it works fine :) phew ! We shouldn't waste time on this stuff...
Bad solution --> DO NOT try to compare e.target's class to the itemRenderer's class of the list, since sometimes e.target is the actual label of the item.
Upvotes: 1
Reputation: 448
You want to listen for MouseEvent.DOUBLE_CLICK
and then you can figure out what was clicked on using event.target
.
Upvotes: 5