为了让我的自定义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
我真的很难过!
答案 0 :(得分:1)
只需为每个人提供一整套代码:
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;
希望这有帮助!