4 Replies Latest reply on Oct 22, 2009 4:42 PM by felixturner

    NativeMenuItem.data disappearing

    David Durkee

      I am trying to add native menu items to my Flex-based AIR app. I'm working on the Mac implementation first. I'm getting the existing menu bar with NativeApplication.nativeApplication.menu, adding a SELECT event listener on it, finding the existing File menu and adding an item to it. The item uses a string in the data field as a command code, so my event handler looks like this:

       

       

              private function onNativeMenuSelect(evt:Event):void

              {

              var itemData:String = evt.target.data;

      switch(itemData)

      {

      case "open":

      onOpenCmd();

      break;

      case "saveAs":

      onSaveAsCmd();

      break;

      default:

      mCurrentWorkspace.DoCommand(itemData);

      }

              }

       

      Unfortunately, this only works once. It appears that after that, the data property on the menu items I added has been set to null. I could add a separate even listener to each menu item, but shouldn't this approach work? Or is soemthing in AIR reserving the data field for something else?

       

      David