Real single line TextField??
You create a TextField with multiline = false, and then publish it, well, you think the textfield just accept single line text, you press Enter, no newline entered, you paste a new line, it is filtered. Seems every thing runs well...
真正单行TextField(文本框)??
你建立一个TextField(译者注:最好把高度调高一些,这样效果明显),设置属性multiline = false,然后发布。现在你觉得这个TextField只接受单行文本,你按回车键。没有新的行加入,你粘贴想显示出新的一行,但是被过滤了。看起来一切正常。
But how about when you press Ctrl+Enter when your swf runs in Internet Explorer? On my machie, new line is entered, the single line textfield became a two line textfield.(Tested on Windows2000+IE6+FP8 plugin)
但是,当你的FLASH运行在一个IE窗口里,你输入Ctrl+Enter,会怎么样呢?在我的机器上,一个新行被加入了,这个单行textfield,变成了两行的textfield。(测试环境:Windows2000+IE6+FP8 plugin)(译者注:经测试在使用IE内核的浏览器都有这现象,而Firefox浏览器则没有。)
This is weird and annoying, but here is a solution:
Add a handler to the onScroller event, when your single line textfield scrolled, means newline is entered, then you can find out the newline code and deleted it from your textfield text, sample code:
这个现象非常奇怪也非常烦人。但是这里有一个解决办法:在onScroller事件上加一个事件处理函数,当你的单行textfield的scroll属性变化时就意味着有一个新行加入了,然后你就可以找出这个新行然后从你的textfield中删除,代码:
yourTextField.onScroller = function(textField:TextField){
var str:String = textField.text;
//only check it when Ctrl or Enter pressed
if(Key.getCode() == Key.CONTROL || Key.getCode() == Key.ENTER){
for(var i:Number=0; i<str.length; i++){
if(str.charCodeAt(i) == 13){
textField.text = str.substring(0, i) + str.substring(i+1);
return;
}
}
}
}
You create a TextField with multiline = false, and then publish it, well, you think the textfield just accept single line text, you press Enter, no newline entered, you paste a new line, it is filtered. Seems every thing runs well...
真正单行TextField(文本框)??
你建立一个TextField(译者注:最好把高度调高一些,这样效果明显),设置属性multiline = false,然后发布。现在你觉得这个TextField只接受单行文本,你按回车键。没有新的行加入,你粘贴想显示出新的一行,但是被过滤了。看起来一切正常。
But how about when you press Ctrl+Enter when your swf runs in Internet Explorer? On my machie, new line is entered, the single line textfield became a two line textfield.(Tested on Windows2000+IE6+FP8 plugin)
但是,当你的FLASH运行在一个IE窗口里,你输入Ctrl+Enter,会怎么样呢?在我的机器上,一个新行被加入了,这个单行textfield,变成了两行的textfield。(测试环境:Windows2000+IE6+FP8 plugin)(译者注:经测试在使用IE内核的浏览器都有这现象,而Firefox浏览器则没有。)
This is weird and annoying, but here is a solution:
Add a handler to the onScroller event, when your single line textfield scrolled, means newline is entered, then you can find out the newline code and deleted it from your textfield text, sample code:
这个现象非常奇怪也非常烦人。但是这里有一个解决办法:在onScroller事件上加一个事件处理函数,当你的单行textfield的scroll属性变化时就意味着有一个新行加入了,然后你就可以找出这个新行然后从你的textfield中删除,代码:
yourTextField.onScroller = function(textField:TextField){
var str:String = textField.text;
//only check it when Ctrl or Enter pressed
if(Key.getCode() == Key.CONTROL || Key.getCode() == Key.ENTER){
for(var i:Number=0; i<str.length; i++){
if(str.charCodeAt(i) == 13){
textField.text = str.substring(0, i) + str.substring(i+1);
return;
}
}
}
}