【问题标题】:Right parentheses in flex with help of keyboard event在键盘事件的帮助下,flex中的右括号
【发布时间】:2010-03-22 23:00:58
【问题描述】:

我正在使用一个文本框,并在按键按下时添加了一个事件侦听器。我想在 charCode(或任何可能的东西)的帮助下知道最后输入的字符。 主要问题是当我想按“(”即右括号时,我无法找到键入的字符。 所有这些东西都在 flex 中。那么有人吗??

【问题讨论】:

    标签: apache-flex


    【解决方案1】:

    这个怎么样:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="onComplete();">
        <mx:Script><![CDATA[
            import flash.events.TextEvent;
            private function onComplete():void
            {
                textInput.addEventListener(TextEvent.TEXT_INPUT, onTextInput);
            }
            private function onTextInput(e:TextEvent):void
            {
                var lastChar:String = e.text.charAt(e.text.length - 1);
                if (lastChar == ")")
                    typed.text = "Right parentheses!!!";
                else
                    typed.text = lastChar;
            }
        ]]></mx:Script>
        <mx:TextInput id="textInput"></mx:TextInput>
        <mx:Label id="typed"></mx:Label>
    </mx:Application>
    

    【讨论】:

      猜你喜欢
      • 2019-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多