MouseDown / MouseMove /单击Flex拖放问题 [英] MouseDown/MouseMove/Click Issues with Flex Drag and Drop

查看:142
本文介绍了MouseDown / MouseMove /单击Flex拖放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flex 3中,我有一个ItemRenderer,其中有一个按钮。我希望用户能够点击并拖动此渲染器,但也只需点击按钮。

In Flex 3, I have an ItemRenderer that has a button in it. I want users to be able to click and drag this Renderer, but also just click the button.

现在,它正在使用Renderer监听MouseMove来启动拖动并放下,按钮上的点击按钮。

Right now it's working with the Renderer listening on "MouseMove" to initiate drag and drop, and the button listening on "click".

然而,这是非常灵活的。如果有人拖动滚动条并且到达该渲染器附近的任何地方,MouseMove将在渲染器上触发并启动拖动。
(或者如果有人正在调整HDividedBox的大小,基本上如果有人在应用程序中的任何地方发起点击并滚动该渲染器,我们会收到不必要的拖动。

However this is very screwy. If somebody is dragging a scroll bar and comes anywhere near that renderer, MouseMove gets fired on the renderer and initiates dragging. (or if somebody is resizing a HDividedBox, basically if someone initiated a click anywhere in the app and rolls over this renderer, we get unwanted dragging.

另一种方法是在MouseDown而不是MouseMove上进行监听,这修复了上一个问题,但是嵌套按钮失去了它的点击,我可以点击按钮,但是渲染器只是认为是拖动的时间。

The alternative is listening on MouseDown instead of MouseMove, which fixes the previous issue, however the nested button loses it's click. I can click on the button, but the renderer just thinks it's time to Drag.

有没有这个?

推荐答案

一个快速,简单的方法来处理这个是通过按钮监听MouseDown,并通过调用 event.stopPropagation()在事件侦听器中。

A quick, easy way to deal with that is by having the button listen to MouseDown, and prevent the event from bubbling up to your Renderer by calling event.stopPropagation() in the event listener.

这篇关于MouseDown / MouseMove /单击Flex拖放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆