如何停止在flex中获取鼠标点击事件

发布于 2024-12-06 17:53:59 字数 170 浏览 0 评论 0原文

我创建了一个层次结构,其中有一个主页,使用添加元素我附加了一个组类型的组件 mxml。主页上有一个按钮,单击时应在该组类型 mxml 组件中添加类型组的子项以及两个按钮。现在,我使用其中一个按钮附加另一个组件 mxml 类型组。问题是即使它们重叠,我仍然可以超出第一组组件 mxml 的子组。我怎样才能阻止这个鼠标事件的发生。

I have made a hierarchy in which there is a main page, using add element i have attached a component mxml of type group. There is a single button on main page when clicked it should add children of type group in that group type mxml component along with two buttons. Now using one of buttons i am attaching another component mxml type group. the problem is even they overlap i can still excess the children groups of first group component mxml. how can i stop this mouse events to happen.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

Bonjour°[大白 2024-12-13 17:53:59

我认为这类事件通常会冒泡到父组件。
您可以尝试在鼠标单击事件侦听器中使用以下代码来停止进一步传播:

private function onMouseClicked(event: MouseEvent): void {
    event.stopPropagation();
    ... do whatever you wanted when smth was clicked ...
}

I think those kind of events usually bubble up to parent components.
You can try using the following code in your mouse click event listener to stop further propagation:

private function onMouseClicked(event: MouseEvent): void {
    event.stopPropagation();
    ... do whatever you wanted when smth was clicked ...
}
心欲静而疯不止 2024-12-13 17:53:59

通过将enabled、mouseChildren、mouseEnabled 设置为false,您将禁用整个组件及其子组件。下面的例子

private var myPreviousGroupComponent:Group = null;
function addNewGroup():void
{
    if(myPreviousGroupComponent != null)
    {
        myPreviousGroupComponent.enabled = false;
        myPreviousGroupComponent.mouseChildren = false;
        myPreviousGroupComponent.mouseEnabled = false;
    }

    var newGroup:Group = new Group();
    addElement(newGroup);

    myPreviousGroupComponent = newGroup;
}

By setting enabled, mouseChildren, mouseEnabled to false, you will disable the entire component and it's children. example below

private var myPreviousGroupComponent:Group = null;
function addNewGroup():void
{
    if(myPreviousGroupComponent != null)
    {
        myPreviousGroupComponent.enabled = false;
        myPreviousGroupComponent.mouseChildren = false;
        myPreviousGroupComponent.mouseEnabled = false;
    }

    var newGroup:Group = new Group();
    addElement(newGroup);

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