Been tearing my hair out for ages trying to get my custom ContextMenu to apply to a TextArea, It will just display the default (copy, paste ect...).
import mx.events.FlexEvent;
public var nm:NativeMenu = new NativeMenu();
public var cm:ContextMenu = new ContextMenu();
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
cm.clipboardMenu = true;
var cmi:ContextMenuItem = new ContextMenuItem("ctest");
cm.addItem(cmi);
TA.contextMenu = cm;
}
given TA is an mx TextArea in MXML
i'm really stumped!
Just to put a full set of code for everyone to see:
var cm:ContextMenu = new ContextMenu();
var menuitem:ContextMenuItem = new ContextMenuItem("Check Spelling");
menuitem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, handleContextMenuEvent);
mainMenu.addItem(menuitem);
textArea.contextMenu = mainMenu;
var txt:TextField = textArea.mx_internal::getTextField() as TextField;
txt.contextMenu = mainMenu;
Hope this helps!