将焦点设置在内部有 TextArea 的列表 ItemRenderer 上?

发布于 2024-09-29 08:25:22 字数 390 浏览 0 评论 0原文

我为 List 组件 (Flex 3.5) 编写了一个自定义 itemrenderer,该组件是一个包含 Label 和 TextArea 的 VBox。到目前为止一切正常,但我希望第一个项目渲染器中的 TextArea 接收焦点,以便在点击列表时它立即变得可编辑。这可能吗?如果我将如何实现这一目标?

我已经添加了一个事件侦听器,用于选择索引 0 处的项目,但其中的 textArea 也应该在此时聚焦......

_list.addEventListener(FocusEvent.FOCUS_IN, onListFocusIn);

private function onListFocusIn(e:FocusEvent):void
{
 _list.selectedIndex = 0;
}

I've wrote a custom itemrenderer for a List component (Flex 3.5) which is a VBox with a Label and a TextArea wrapped inside. All works fine so far but I want the TextArea in the first itemrenderer to receive focus so that it instantly becomes editable when tabbing onto the List. Is that possible and if how would I achieve this?

I've already added an event listener that selects the item at index 0 but the textArea in it should also be focussed at that moment ...

_list.addEventListener(FocusEvent.FOCUS_IN, onListFocusIn);

private function onListFocusIn(e:FocusEvent):void
{
 _list.selectedIndex = 0;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

简单气质女生网名 2024-10-06 08:25:22

没有太多的活动。一种黑客方法是覆盖 itemRenderer 的 updateDisplayList

<mx:Script>
    <![CDATA[
        import mx.controls.listClasses.ListBase;
        import mx.managers.FocusManager;

        override protected function updateDisplayList(unscaledWidth:Number, 
                                                      unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            if(ListBase(owner).isItemSelected(data)){
                focusManager.setFocus(mytext);
             }
        } 
    ]]>
</mx:Script>

更多详细信息
http://butterfliesandbugs。 wordpress.com/2007/06/25/how-to-know-when-my-itemrenderer-is-selected/

http://cookbooks.adobe.com/post_How_to_know_when_an_ItemRenderer_is_selected-5322.html

There isn't much of an event for that. One hackery way to do it is to override updateDisplayList for your itemRenderer

<mx:Script>
    <![CDATA[
        import mx.controls.listClasses.ListBase;
        import mx.managers.FocusManager;

        override protected function updateDisplayList(unscaledWidth:Number, 
                                                      unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            if(ListBase(owner).isItemSelected(data)){
                focusManager.setFocus(mytext);
             }
        } 
    ]]>
</mx:Script>

More details on
http://butterfliesandbugs.wordpress.com/2007/06/25/how-to-know-when-my-itemrenderer-is-selected/

And

http://cookbooks.adobe.com/post_How_to_know_when_an_ItemRenderer_is_selected-5322.html

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