2012-01-12 22 views
0

ボタンをクリックしたときにリッチテキストエディタに日付を挿入したいと思います。 この部分は、カーソルの位置に挿入するのが簡単で難しくなります。カーソルの位置は、テキストの先頭、途中、または末尾にあることがあります。そのような単純なRichTextEditorのテキストをカーソル位置に挿入

答えて

1

を支援するための

ありがとう:

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)"/> 

はEDIT: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)"/> 

多分もっと効果的な方法がありますが、これが私が考えることができるのです。

+0

ありがとうございますが、 Flex60460

+0

私はコードを更新しましたが、これはあなたに適しています。 – randomUser56789

+0

ありがとうございました。それはうまくいく! – Flex60460

関連する問題