MouseDown/MouseMove/Click Issues with Flex Drag and Drop

别等时光非礼了梦想. 提交于 2020-02-02 14:35:12

问题


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.

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

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.

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.

Is there anyway around this?


回答1:


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.



来源:https://stackoverflow.com/questions/1430227/mousedown-mousemove-click-issues-with-flex-drag-and-drop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!