Flex: TextInput 监听回车事件

Categories: Flex; Tagged with: ; @ November 13th, 2009 21:12

有时候需要监听TextInput的回车按下事件, 以直接进行某操作.

可使用FlexEvent.ENTER如:

_textKeywords.addEventListener(FlexEvent.ENTER, onTextKeyWordsEnterPressed);

Flex: 输入组件 – TextInput, ComboBox, Radiobutton, TextArea等 对其输入内容进行验证

Categories: 垃圾山; Tagged with: ; @ February 20th, 2009 14:01

如: 某编辑器:

image

代码:

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,.