apache-flexright-clickricheditabletext

Detect right clicks on a RichEditableText


I am currently implementing squiggly in a flex application to enable spell checking. Due to certain requirements, I can not use SquigglyUI to hook onto my spark RichEditableText. I have successfully used com.adobe.linguistics.utils.TextTokenizer to tokenize and highlight mispelt words.

I would like to be able to let the user rightclick on a mispelled word and show a list of suggestions in the context menu using getSuggestions.

I have tried to attach a listener to my RichEditableText:

richtexteditor.addEventListener("rightClick", showSuggestions);

And this is my event handler:

private function showSuggestions(event:MouseEvent):void{
    trace('hi there');
}

The problem is when debugging the application, I never get the trace in my console as the rightclick event is never dispatched. In addition, I need to detect the word the user has right clicked on. How can I go about doing this and how can I detect right clicks?

Cheers


Solution

  • All I had to do was add an event handler to the contextmenu property of the richeditable text:

    richtexteditor.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, doSomething);