0 Replies Latest reply on Jan 11, 2008 3:05 PM by TheKeck

    Custom Context Menu Not Working

    TheKeck
      I am trying to add a custom context menu to a UI widget. (It happens to be an accordian, but I've tried with several different widgets.) The custom items on my context menu will not show up.

      I am just playing around with trying to get it to work, and so currently I pretty much have the example code pasted in from the contextMenu documentation. I have even debugged into the event listener of the context menu and traversed the structure of the contextMenu object. My custom items all appear to be present, enabled, and visable according to the debugger, but they don't actually show up on screen.

      Any idea what I'm doing wrong? Is it possible that this is a bug?




      Here's the relevant code:

      private var editContextMenu:ContextMenu;

      private function init():void
      {
      main_nav.contextMenu = createContextMenu();
      }

      private function createContextMenu():ContextMenu
      {
      editContextMenu = new ContextMenu();
      editContextMenu.hideBuiltInItems();
      var cutItem:ContextMenuItem = new ContextMenuItem("Cut");
      cutItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doCutCommand);
      editContextMenu.customItems.push(cutItem);

      var copyItem:ContextMenuItem = new ContextMenuItem("Copy");
      copyItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doCopyCommand);
      editContextMenu.customItems.push(copyItem);

      var pasteItem:ContextMenuItem = new ContextMenuItem("Paste");
      pasteItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doPasteCommand);
      editContextMenu.customItems.push(pasteItem);

      editContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);

      return editContextMenu;
      }

      private function menuSelectHandler(event:ContextMenuEvent):void
      {
      trace("menuSelectHandler: " + event);
      }