Flex 3:确定事件目标是否是组件的后代

发布于 2024-10-03 03:50:14 字数 399 浏览 0 评论 0原文

我有一个带有几个文本输入字段(除其他外)的自定义组件,用作树中的行组件。我必须编写自己的拖放处理,并且几乎完成了启动处理程序(我上次完成的),使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无妨# 2024-10-10 03:50:14

使用 myComponent.contains(child)。

PS:当myComponent == child时,它也会返回true

Use myComponent.contains(child).

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

你是我的挚爱i 2024-10-10 03:50:14

您可以创建一个“标记”接口(即没有方法或属性的接口),然后

if ( yourObject is IYourInterface) {

在代码中询问。

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

if ( yourObject is IYourInterface) {

in your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文