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