2012-01-12 52 views

回答

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

编辑:对于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 2012-01-12 16:09:11

+0

我已更新的代码,这一个应该适合你。 – randomUser56789 2012-01-13 07:38:40

+0

非常感谢。它运作良好! – Flex60460 2012-01-13 09:40:52

相关问题