s:TextArea禁止回车,cancelable为true但事件的preventDefault无效

xytx_823 2015-04-02 03:03:18
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
private function textArea_textInput(evt:TextEvent):void {
if (evt.text == String.fromCharCode(13)) {
trace(evt.cancelable);
evt.preventDefault();
}
}
]]>
</fx:Script>

<s:VGroup>
<s:TextArea id="textArea" width="100%" height="100%" textInput="textArea_textInput(event)"/>
</s:VGroup>
</s:Application>
cancelable打印是true,但是文本框中
...全文
184 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xytx_823 2015-04-02
  • 打赏
  • 举报
回复
但是文本框中还是能够输入回车

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧