smu*_*nd2 1 apache-flex mxml textarea actionscript-3 flash-builder
我在表格上有一个文本区域控件,应该接受5位美国邮政编码.我已经为控件分配了一个keyUp事件,该事件检查输入的字符数,直到达到5然后强制换行.
public function forceNewLine(event:KeyboardEvent):void
{
var maxLineChars:int = 5;
var currentLine:int = 1;
var numChars:int;
numChars = (txtList.text.length);
currentLine = Math.round(txtList.text.length / 6);
if (numChars == (maxLineChars * currentLine))
{
txtList.text = txtList.text + "\n";
txtList.setCursorPosition()
//This is not a function I have defined but I think I need too..
}
}
<s:TextArea id="txtList" keyUp="forceNewLine(event)"/>
Run Code Online (Sandbox Code Playgroud)
它工作正常,除了插入新行时,光标移动到textarea的开头.我想让它走到尽头.
尝试使用spark textArea的selectRange函数.
txtList.selectRange(txtList.text.length, txtList.text.length)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2286 次 |
| 最近记录: |