我有一个带有 itemrenderer 的列表。当我在 itemrenderer 中放置一个按钮时,我无法与之交互。如果我翻转按钮,则会触发列表项翻转,但不会触发按钮的翻转。我也不能点击按钮。您可以在下面看到我在 itemrenderer 中设置了一个点击事件,并且在我运行应用程序时不会在点击时调用它。我必须覆盖 itemrender 的翻转和单击方法吗?为什么在 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>