Flex无法与itemrenderer中的按钮进行交互
问题描述:
我有一个带有itemrenderer的列表。当我在itemrenderer中放置一个按钮时,我无法与它进行交互。如果我滚动按钮,列表项翻转被触发,但不是按钮的翻转。我也无法点击按钮。您可以在下面看到我在itemrenderer中设置了一个单击事件,并且在运行应用程序时不会单击它。我必须重写滚动并单击itemrender的方法吗?为什么把一个按钮放在一个itemrenderer中是一件很痛苦的事情?我肯定错过了什么。谢谢。Flex无法与itemrenderer中的按钮进行交互
<!---From main.mxml-->
<s:List width="100%" borderVisible="false"
itemRenderer="itemRenderers.data_resultLayersRenderer"
dataProvider="{resultsLayers}"/>
<!---From itemRenderes-->
<s:ItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:skins="skins.*" autoDrawBackground="true">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
[Bindable]
[Embed('images/add2.png')]
public var addIcon:Class;
[Bindable]
[Embed('images/delete2.png')]
public var deleteIcon:Class;
protected function iconbutton1_clickHandler(event:MouseEvent):void
{
Alert.show('test');
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
<s:State name="hovered"/>
</s:states>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:transitions>
<mx:Transition toState="hovered">
<s:Animate target="{item}" duration="200">
<s:SimpleMotionPath property="borderWeight" />
</s:Animate>
</mx:Transition>
<mx:Transition fromState="hovered">
<s:AnimateColor target="{item}" duration="200"/>
</mx:Transition>
</s:transitions>
<mx:HBox id="item" verticalAlign="middle" width="100%" height="100%"
useHandCursor="true" buttonMode="true" mouseChildren='false'
paddingTop="5" paddingBottom="5">
<s:Label id="subMenuItemName" text="{data.name}"
color="#000000" color.hovered="#ff9a15"
fontSize="12" fontWeight.hovered="bold"
fontFamily="Georgia"/>
<s:Label text="{'(' + data.result + ')'}"
id="subMenuItemDescription"
color="#333333" color.hovered="#ff9a15"
fontSize="10"/>
<skins:IconButton
label="Remove"
icon="{deleteIcon}"
skinClass="skins.iconButtonSkin"
color="#ffffff"
/>
<skins:IconButton
label="Add"
icon="{addIcon}"
skinClass="skins.iconButtonSkin"
color="#ffffff"
click="iconbutton1_clickHandler(event)"
/>
</mx:HBox>
答
看起来像你有mouseChildren
设置为您的项目渲染器中的fase。通过将此属性设置为false,可以停止将任何鼠标事件传播到容器的子项。尝试将其设置为true,看看会发生什么。
就是这样。谢谢你,先生! – mrjrdnthms 2010-05-28 22:44:34