views:

330

answers:

2

I'm trying to enable a double click event on a flex control without disabling the default mouseup/mousedown behaviors.

I'm using the ESRI Flex API for arcgis server, and I have a map control with one background layer and a GraphicLayer. The graphics layer has several Graphic objects that respond to mouseover, and allow the user to pan the map if they click and hold. However, when I implement a double click event handler for the graphic objects, they no longer seem to bubble up their default behavior to the map.

Is there a way to implement a double click on a Graphic object while preserving the old behavior from clicking and holding?

+1  A: 

I solved this by attaching the double click event to the map, rather than the graphic, and using the target attribute of the event to get the graphic I wanted to use.

Like this:

map.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void
{
    var graphic:Graphic = event.target as Graphic;
    if(graphic)
    {
        ...
    }
});
Dan Monego
+1  A: 

If you set the "checkForMouseListeners" property to false on your Graphic objects, then the default map click/drag behavior will be preserved.

graphic.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void {
    var graphic:Graphic = event.target as Graphic;
    if(graphic) {
      ...
    }
});

//preserve the default click/drag behavior on the map
graphic.checkForMouseListeners = false;

http://resources.esri.com/help/9.3/ArcGISServer/apis/Flex/apiref/com/esri/ags/Graphic.html#checkForMouseListeners

David Mills