【问题标题】:Spark Button not triggering onClick EventSpark Button 未触发 onClick 事件
【发布时间】:2013-07-01 17:57:07
【问题描述】:

我从 air 3.1 更新到 air 3.7,现在似乎无法单击一个可以正常工作的按钮。

按钮位于火花VGroup 内。

<s:Group id="noConnection" visible="false" alpha="0.9">
    <s:Rect width="{Utils.application.width}" height="{Utils.application.height}">
        <s:fill><s:SolidColor color="0xFFFFFF" /></s:fill>
    </s:Rect>
    <s:VGroup id="vgroup" verticalAlign="middle" verticalCenter="0"
        horizontalAlign="center" horizontalCenter="0">
        <s:Button label="Try again" click="retry_clickHandler(event)" />
        <s:Label text="No connection"/>
    </s:VGroup>
</s:Group>

在上面的代码中,当我按下按钮时,不会触发 MouseEventTouchEvent。 (它也没有动画)。

但是,如果从 VGroup 属性中删除 verticalAlign" ,verticalCenterhorizo​​ntalAlignandhorizo​​ntalCenter`,该按钮将再次正常工作。

像这样:

<s:Group id="noConnection" visible="false" alpha="0.9">
    <s:Rect width="{Utils.application.width}" height="{Utils.application.height}">
        <s:fill><s:SolidColor color="0xFFFFFF" /></s:fill>
    </s:Rect>
    <s:VGroup id="vgroup">
        <s:Button label="Try again" click="retry_clickHandler(event)" />
        <s:Label text="There's no connection" />
    </s:VGroup>
</s:Group>

知道为什么会这样吗?

谢谢

【问题讨论】:

  • 只是一个疯狂的猜测,但它闻起来像其他东西(透明)覆盖你的按钮;这就是为什么当您通过删除其定位属性将 Button 移动到其他位置时它会按预期工作的原因。
  • @RIAstar 会是矩形吗?除了这个组之外,视图中没有其他内容。
  • @DanDinu VGroup 位于Rect 之上,因此Rect 不会干扰VGroup 上的鼠标。至于视图中的其他内容,这个Group 的父级是什么?你如何让它可见?您的应用程序屏幕上还有哪些其他内容?答案可能在使这一切发生的代码中,但又可能不是:)
  • 您可以尝试使用fxspy 来确定按钮顶部是否真的有东西。

标签: apache-flex flex4.6 flex-spark


【解决方案1】:

当我运行以下代码时,一切运行良好。只有我不明白为什么您将父组的可见性设为假。 请检查以下修改代码:

<s:Group id="noConnection" visible="true" alpha="0.9">
 <s:Rect width="400" height="400">
     <s:fill><s:SolidColor color="0xFFFFFF" /></s:fill>
 </s:Rect>
 <s:VGroup id="vgroup" verticalAlign="middle" verticalCenter="0"
                      horizontalAlign="center" horizontalCenter="0">
  <s:Button label="Try again" click="retry_clickHandler(event)" />
  <s:Label text="No connection"/>
  </s:VGroup>
 </s:Group>

【讨论】:

    猜你喜欢
    • 2013-03-12
    • 2013-04-25
    • 2012-01-24
    • 1970-01-01
    • 2020-01-31
    • 2013-04-30
    • 2011-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多