Flex 3:确定事件目标是否是组件的后代
我有一个带有几个文本输入字段(除其他外)的自定义组件,用作树中的行组件。我必须编写自己的拖放处理,并且几乎完成了启动处理程序(我上次完成的),使用 mouseDown 作为启动事件。
它基本上可以工作,但是当树足够扩展以至于显示滚动条时,使用滚动条同时拖动树的一行!不是期望的行为。
在调试器中查看,我可以看到当拖动树的一行时,currentTarget是树本身,目标是textInput组件。查看该组件的父级,我可以看到我的自定义组件(包含 textInput)上升了几个级别。
我的问题是,是否有一种简单的方法来确定该目标是否是我的组件的后代,以便只有在这种情况下我才能启动拖动?
顺便说一句, event.target 不起作用......这是我所期望的,因为它不是!
谢谢,
迈克
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. Looking 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 myComponent.contains(child)。
PS:当
myComponent == child
时,它也会返回true
。Use
myComponent.contains(child)
.P.S: It also returns
true
whenmyComponent == child
.您可以创建一个“标记”接口(即没有方法或属性的接口),然后
在代码中询问。
You could create a 'marker' interface (i.e. one with no methods or properties) , and then ask
in your code.