0
当用户单击某个按钮时,我会在richtexteditor上插入日期。 这部分很容易,比较困难,如何将它插入光标位置。光标位置可能在文本的开始,中间或结尾。在光标位置插入RichTextEditor中的文本
感谢您的帮助
当用户单击某个按钮时,我会在richtexteditor上插入日期。 这部分很容易,比较困难,如何将它插入光标位置。光标位置可能在文本的开始,中间或结尾。在光标位置插入RichTextEditor中的文本
感谢您的帮助
就这么简单:
protected function richText_keyDownHandler(event:KeyboardEvent):void
{
if (event.keyCode == 66) //or remove if statement
richText.insertText("Really?");
}
<s:RichEditableText id="richText" text="Lorem ipsum dolor sit amet"
keyDown="richText_keyDownHandler(event)"/>
编辑:对于MX RichTextEditor
protected function richText_keyDownHandler(event:KeyboardEvent):void
{
var ind:int = richEdit.selection.beginIndex;
richEdit.text = richEdit.text.substring(0, ind) +
"Your text variable here" +
richEdit.text.substring(ind, richEdit.text.length);
}
和MX富文本编辑器:
<mx:RichTextEditor id="richEdit" text="Lorem ipsum dolor sit amet"
keyDown="richText_keyDownHandler(event)"/>
也许有更有效的方法,但这是我能想到的唯一方法。
感谢但与
Flex60460
2012-01-12 16:09:11
我已更新的代码,这一个应该适合你。 – randomUser56789 2012-01-13 07:38:40
非常感谢。它运作良好! – Flex60460 2012-01-13 09:40:52