我希望删除特定的字符在星火TextInput中,而用户键入它,不造成任何干扰,如舔后的最后一个字符或类似的鼠标。
感谢
发布于 2011-06-15 13:00:48
您可以创建自己的自定义TextInput组件并重写keyDownHandler(),也可以在TextInput上添加事件侦听器,如下所示:
<s:TextInput keyDown="{ textInputKeyDownHandler(event) }"/>然后在事件处理程序上:
private function textInputKeyDownHandler(event:KeyboardEvent):void {
// Make your validations and if necessary, use the following command
// to prevent the character from being added to the TextInput
event.preventDefault();
}这样,字符就不会添加到TextInput中,这意味着文本属性和光标位置不会改变。
注意:使用event.charCode和event.keyCode进行必要的验证。
发布于 2011-06-15 10:16:35
您是否尝试过限制TextInput的属性?我不知道你的具体角色是什么,但通常有两种限制。仅限于一组字符:
<s:TextInput restrict="A-Za-z" />允许除某些特殊字符外的所有字符:
<s:TextInput restrict="^0-9" />要处理unicode字符,请使用\u:
<s:TextInput restrict="\u0239" />https://stackoverflow.com/questions/6355021
复制相似问题