问题
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