views:

1260

answers:

1

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?

+2  A: 

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.

BernzSed
thanks, that looks like it'll work just fine.
icepack