有时候需要监听TextInput的回车按下事件, 以直接进行某操作.
可使用FlexEvent.ENTER如:
_textKeywords.addEventListener(FlexEvent.ENTER, onTextKeyWordsEnterPressed);
如: 某编辑器:
代码:
textName.addEventListener(Event.CHANGE, onTextNameChange);//增加监听函数,监听EventChange, 如果不需实时验证, 可监听FlexEvent.VALUE_COMMIT事件. //------------------Validation - Name - on Event.Change------------ private function onTextNameChange(e:Event = null):void { if(StringUtils.trim(textName.text).length < 2) { textName.errorString = "Name不能少于2个字符, 请重新输入"; }else if(StringUtils.trim(textName.text) == "String") { textName.errorString = "Name不可为'String'"; }else { textName.errorString = null; } setButton(); }
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.