多年来我一直在努力让我的自定义ContextMenu应用到TextArea,它只会显示默认值(复制,粘贴等)。
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;
}
给定TA是MXML中的mx TextArea
我真的被难住了!只是为了放一套完整的代码给大家看:
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;
希望这对你有帮助!