设置双击事件而不禁用默认的 mouseup/mousedown 行为

发布于 2024-08-18 10:49:11 字数 257 浏览 5 评论 0原文

我试图在 Flex 控件上启用双击事件,而不禁用默认的 mouseup/mousedown 行为。

我正在使用用于 arcgis 服务器的 ESRI Flex API,并且我有一个带有一个背景层和一个 GraphicLayer 的地图控件。图形层有几个响应鼠标悬停的 Graphic 对象,并允许用户在单击并按住时平移地图。但是,当我为图形对象实现双击事件处理程序时,它们似乎不再将其默认行为冒泡到地图上。

有没有办法实现图形对象上的双击,同时保留旧的单击和按住行为?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终陌 2024-08-25 10:49:11

我通过将双击事件附加到地图而不是图形,并使用事件的目标属性来获取我想要使用的图形来解决这个问题。

像这样:

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

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)
    {
        ...
    }
});
回首观望 2024-08-25 10:49:11

如果您将 Graphic 对象上的“checkForMouseListeners”属性设置为 false,则将保留默认的地图单击/拖动行为。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文