I'm using RichTextEditor in my AIR desktop application, built with flex 3.6.
Since there's no undo/redo management, I'm trying to extend the component functionality.
I got a function I got a problem everytime CTRL+Y are pressed.
This what I actually do when a key is pressed.
<mx:RichTextEditor
id="myRTE"
keyDown="onKeyDown(event);"
/>
....
public function onKeyDown(event:KeyboardEvent):void
{
if (event.ctrlKey && event.charCode == 122)
{
// ctrl + z pressed!
undo();
}
if (event.ctrlKey && event.charCode == 121)
{
// ctrl + y pressed!
redo();
}
}
My problem is that CTRL + Y output also a weird char in my RichTextEditor but i would like to discard it.
I tried to put a event.stopImmediatePropagation(); just after the redo(); but the weird char is appended to my RichTextEditor anyway.
I really don't know how get rid of that.
Any idea?
You can use this code:
protected function application1_creationCompleteHandler(event:FlexEvent):void {
myRTE.textArea.addEventListener(TextEvent.TEXT_INPUT, textInput);
}
private function textInput(event:TextEvent):void {
// <CTRL+V pressed
if (event.text.length > 1)
event.preventDefault();
}
RichTextEditor encapsulate and using TextArea. You can add event for TextEvent.TEXT_INPUT to prevent CTRL+V event.