开发者

Flex 3: determine if an event target is a descendant of a component

I have a custom component with a couple of text input fields (among other things) that is used as the row components in a tree. I have had to write my own drag and drop handling, and have almost finished the start handler (which I did last), using mouseDown as the event to kick if off.

It basically works, but when the tree is expanded enough so that a scroll bar shows, using the scroll bar drags a row of the tree at the same time ! Not the desired behaviour.

Looking in the debugger, I can see that when a row of the tree is dragged the currentTarget is the tree itself, and the target is the textInput component. Lo开发者_StackOverflow中文版oking at the parents of that component I can see my custom component (that contains the textInput) a couple of levels up.

My question is, is there an easy way to determine if this target is descended from my component, so that I can initiate a drag only if that is the case ?

event.target is doesn't work by the way....which I kind of expected, because it isn't !

Thanks,

Mike


Use myComponent.contains(child).

P.S: It also returns true when myComponent == child.


You could create a 'marker' interface (i.e. one with no methods or properties) , and then ask

if ( yourObject is IYourInterface) {

in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜