[Flash] Context Menu issue


原來cut,copy,delete 都是reserved word。
所以當create 一個context menu 的時候就not work。

即使在字後面加whitespace 都是不行

the trick of putting a space after the words, i.e. “copy “. That did not work.

但是原來只要用non-breaking character 就可以了。whitespace 的non-breaking character 是“\u00A0″.

elementContextMenu = new ContextMenu();
elementContextMenu.hideBuiltInItems();
 
var cutItem:ContextMenuItem = new ContextMenuItem("Cut\u00A0");
var copyItem:ContextMenuItem = new ContextMenuItem("Copy\u00A0");
var pasteItem:ContextMenuItem = new ContextMenuItem("Paste\u00A0");
 
cutItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onCutItem);
copyItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onCopyItem);
pasteItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onPasteItem);
 
elementContextMenu.customItems.push(cutItem);
elementContextMenu.customItems.push(copyItem);
elementContextMenu.customItems.push(pasteItem);
 
Application.application.contextMenu = elementContextMenu;

Source: http://www.themorphicgroup.com/blog/2009/07/06/contextmenu-copy-paste-delete/

Share
  1. No comments yet.
(will not be published)

Anti-Spam Protection by WP-SpamFree