开发者

Set a double click event without disabling default mouseup/mousedown behavior

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?


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)
    {
        ...
    }
});


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜