无法与 Flex 4 Gumbo 中的 itemRenderer 的子级交互
我以为这很容易,但我遇到了各种各样的问题。我有一个带有图像和两个标签的 ItemRenderer。我想为图像和两个标签分配单独的鼠标事件。项目渲染器似乎被视为单个交互式片段,但我还没有找到覆盖它的方法。我什至无法禁用默认的翻转效果,因此我必须设置 rollOverColor 的样式以匹配我的背景。
谁能提供解决方案吗?
<s:DataGroup id="browserDataGroup" dataProvider="{model.userBoardList}"
verticalCenter="0" left="10" rollOverColor="0x424242"
itemRenderer="edu.xxxxx.components.board.BrowserItemRenderer">
<!--itemrenderer code below -->
<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/halo"
xmlns:ns="library://ns.adobe.com/flex/mx"
buttonMode="true" useHandCursor="true"
mouseChildren="true">
<s:states>
<s:State name="up"/>
<s:State name="over"/>
</s:states>
<s:layout>
<s:VerticalLayout gap="2"/>
</s:layout>
<s:Group>
<ns:Image id="image" source="{data.thumbnail}"
addedEffect="Fade" completeEffect="Fade" removedEffect="Fade"
width="130" height="89"
horizontalCenter="0" verticalCenter="0"/>
<s:Rect id="imageRect" width="130" height="89">
<s:stroke>
<s:SolidColorStroke color="0xFFFFFF" joints="miter" pixelHinting="true"/>
</s:stroke>
</s:Rect>
</s:Group>
<s:Label text="{data.title}" color="0xFFFFFF" fontWeight="bold"/>
<s:Group>
<s:layout>
<s:HorizontalLayout gap="3"/>
</s:layout>
<s:Label text="Edit" color="0xFFFFFF" click="trace('edit');"
textDecoration.up="underline" textDecoration.over="none"/>
<s:Label text="|" color="0xFFFFFF"/>
<s:Label text="Delete" color="0xFFFFFF" click="trace('delete');"
textDecoration.up="underline" textDecoration.over="none"/>
</s:Group>
</s:ItemRenderer>
I thought this would be pretty easy but I'm running into all sorts of problems with this. I have an ItemRenderer with a an image and two labels. I want to assign separate mouse events to the image and two labels. It seems like the item renderer is treated like a single interactive piece and I haven't found a way to override that. I couldn't even disable the default rollover effect so I had to style the rollOverColor to match my background.
Can anyone provide a solution?
<s:DataGroup id="browserDataGroup" dataProvider="{model.userBoardList}"
verticalCenter="0" left="10" rollOverColor="0x424242"
itemRenderer="edu.xxxxx.components.board.BrowserItemRenderer">
<!--itemrenderer code below -->
<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/halo"
xmlns:ns="library://ns.adobe.com/flex/mx"
buttonMode="true" useHandCursor="true"
mouseChildren="true">
<s:states>
<s:State name="up"/>
<s:State name="over"/>
</s:states>
<s:layout>
<s:VerticalLayout gap="2"/>
</s:layout>
<s:Group>
<ns:Image id="image" source="{data.thumbnail}"
addedEffect="Fade" completeEffect="Fade" removedEffect="Fade"
width="130" height="89"
horizontalCenter="0" verticalCenter="0"/>
<s:Rect id="imageRect" width="130" height="89">
<s:stroke>
<s:SolidColorStroke color="0xFFFFFF" joints="miter" pixelHinting="true"/>
</s:stroke>
</s:Rect>
</s:Group>
<s:Label text="{data.title}" color="0xFFFFFF" fontWeight="bold"/>
<s:Group>
<s:layout>
<s:HorizontalLayout gap="3"/>
</s:layout>
<s:Label text="Edit" color="0xFFFFFF" click="trace('edit');"
textDecoration.up="underline" textDecoration.over="none"/>
<s:Label text="|" color="0xFFFFFF"/>
<s:Label text="Delete" color="0xFFFFFF" click="trace('delete');"
textDecoration.up="underline" textDecoration.over="none"/>
</s:Group>
</s:ItemRenderer>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以防万一这对其他人有帮助,结果证明解决方案是对
itemRenderer
实例使用 setautoDrawBackground="false"
。这会禁用叠加层的绘制。然后,我应该对我想要与之交互的各个孩子使用rollOver
和rollOut
。新手犯的错误……你讨厌看到它们。Just in case this helps anyone else, turns out the solution was to use set
autoDrawBackground="false"
for theitemRenderer
instance. That disables the drawing of the overlays. Then, I should have been usingrollOver
androllOut
for the individual children that I wanted to interact with. Rookie mistakes…you hate to see them.