【问题标题】:How can I listen for focusIn and focusOut events for a Spark TextArea?如何监听 Spark TextArea 的 focusIn 和 focusOut 事件?
【发布时间】:2011-02-16 18:58:05
【问题描述】:

我正在编写一个 flex 应用程序,并且我有两个 Spark TextArea。我想创建一个 EventListener,这样当用户点击一个文本区域时,TextArea 内的文本就会被清除:

this.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);


   private function onFocusIn(ev:FocusEvent):void {
        if (this._showsCaption) {
            this._showsCaption = false;
            super.text = "";
        }
    }

目前我可以使用 Spark TextInput 来实现这一点,但是当我单击 TextArea 时,focusIn 事件永远不会触发,并且永远不会调用 onFocusIn() 处理程序。

任何想法将不胜感激。

【问题讨论】:

    标签: apache-flex focus textarea event-listener


    【解决方案1】:

    当您扩展 TextArea(如您的情况)时,您可以覆盖受保护的“focusInHandler”方法。这是当控件获得焦点时调用的处理程序。 “focusOutHandler”方法也是如此。

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UIComponent.html#focusInHandler()

    【讨论】:

    • 谢谢 - 这就是我正在寻找的答案。我会投票,但我是 StackOverflow 的新手,没有特权
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-26
    • 1970-01-01
    • 2013-03-08
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多