无法与 Flex 4 Gumbo 中的 itemRenderer 的子级交互

发布于 2024-08-25 17:17:18 字数 2051 浏览 7 评论 0原文

我以为这很容易,但我遇到了各种各样的问题。我有一个带有图像和两个标签的 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 技术交流群。

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

发布评论

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

评论(1

谢绝鈎搭 2024-09-01 17:17:18

以防万一这对其他人有帮助,结果证明解决方案是对 itemRenderer 实例使用 set autoDrawBackground="false" 。这会禁用叠加层的绘制。然后,我应该对我想要与之交互的各个孩子使用 rollOverrollOut 。新手犯的错误……你讨厌看到它们。

Just in case this helps anyone else, turns out the solution was to use set autoDrawBackground="false" for the itemRenderer instance. That disables the drawing of the overlays. Then, I should have been using rollOver and rollOut for the individual children that I wanted to interact with. Rookie mistakes…you hate to see them.

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