Set a double-click event without disabling the default mouse behavior of the mouse / mousedown

I am trying to enable a double-click event on a flexible control without disabling the default mouse behavior of the / mousedown mouse.

I am using the ESRI Flex API for the arcgis server and I have a map control with one background layer and graphic layer. The graphic layer has several Graphic objects that respond to mouse hover and allow the user to pan the map if they are pressed and held. However, when I implement the double-click event handler for graphical objects, they no longer seem to bubble by default with respect to the map.

Is there a way to double-click on a Graphic object while maintaining the old behavior by clicking and holding?

+3
source share
2 answers

I solved this by adding a double-click event to the map, not the graphic, and using the event's target attribute to get the graphic that I wanted to use.

Like this:

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

If you set the "checkForMouseListeners" property to false on your Graphic objects, then the default mouse 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

+3
source

Source: https://habr.com/ru/post/1728974/


All Articles