2 Replies Latest reply on Oct 20, 2008 11:08 PM by kiwi_ziesch

    Menu items

    kiwi_ziesch Level 1

      I have a native menu in my application. But I won´t show all menu items at the start. How can I hide items and activate them later?

      here comes my AIRMenus.js:

      /* AIR Menus HTML application logic **/
      var popUp;
      var eventLog;

      var macStandardModifier = air.Keyboard.COMMAND;
      var winStandardModifier = air.Keyboard.CONTROL;
      var standardModifier;

      var macQuitLabel = "Beenden";
      var winQuitLabel = "Schließen";
      var quitLabel;

      //Sets the system tray or dock icon with the loaded image
      var iconLoadComplete = function(event)
      air.NativeApplication.nativeApplication.icon.bitmaps = new runtime.Array(event.target.content.bitmapData);

      //Creates the menus
      function AIRMenus(){
      //Set OS-specific variables
      var preface = document.getElementById("preface");
      var currentOS = air.Capabilities.os;
      var containsWindows = currentOS.search("Windows");
      if(containsWindows > -1){
      standardModifier = winStandardModifier;
      quitLabel = winQuitLabel;
      } else {
      standardModifier = macStandardModifier;
      quitLabel = macQuitLabel;

      //For application menu (on MAC OS X)
      air.NativeApplication.nativeApplication.menu = createRootMenu("application menu");

      //Create Dock menu and set icon image
      air.NativeApplication.nativeApplication.icon.menu = createRootMenu("dock icon menu");
      var dockIconLoader = new runtime.flash.display.Loader();
      dockIconLoader.load(new air.URLRequest("icons/AIRApp_128.png"));

      //For window menu (on Microsoft Windows)
      window.nativeWindow.menu = createRootMenu("window menu");

      //Create system tray icon menu, tooltip and set the image so that the icon will be shown
      air.NativeApplication.nativeApplication.icon.tooltip = "AIR Menus HTML";
      air.NativeApplication.nativeApplication.icon.menu = createRootMenu("system tray icon menu");
      var systrayIconLoader = new runtime.flash.display.Loader();
      systrayIconLoader.contentLoaderInfo.addEventListener(air.Event.COMPLETE,iconLoadComplete) ;
      systrayIconLoader.load(new air.URLRequest("icons/AIRApp_16.png"));

      window.htmlLoader.contextMenu = createRootMenu("htmlLoader context menu");

      //Create the pop-up menu
      popUp = createRootMenu("pop-up menu");

      //Activate this window so that it will be visible

      //Get a reference to the eventLog element where the selection events are displayed
      eventLog = document.getElementById("eventLog");

      //Displays the pop-up menu
      function popUpMenu(event){
      popUp.display(window.nativeWindow.stage, event.clientX, event.clientY);

      //Displays the context menu
      function showContextMenu(event){
      window.htmlLoader.contextMenu.display(window.nativeWindow.stage, event.clientX, event.clientY);

      function createRootMenu(menuType){
      var menu = new air.NativeMenu();
      return menu;

      function createFileMenu(menuType){
      var temp;
      var menu = new air.NativeMenu();
      temp = menu.addItem(new air.NativeMenuItem("Bilder importieren"));
      temp.keyEquivalent = 'i';
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doImportPic);
      temp = menu.addItem(new air.NativeMenuItem("Ordner importieren"));
      temp.keyEquivalent = 'o';
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doImportDir);
      menu.addItem(new air.NativeMenuItem("",true));//separator
      temp = menu.addItem(new air.NativeMenuItem(quitLabel));
      temp.keyEquivalent = 'q';
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doCloseApp);

      return menu;

      function createEditMenu(menuType){
      var temp;
      var menu = new air.NativeMenu();
      temp = menu.addItem(new air.NativeMenuItem("Metadatenvorlage"));
      temp.keyEquivalent = 'm';
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doModel);
      temp = menu.addItem(new air.NativeMenuItem("Stichwortkatalog"));
      temp.keyEquivalent = 'k';
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doCatalogue);

      return menu;

      function createPrefMenu(menuType){
      var temp;
      var menu = new air.NativeMenu();
      temp = menu.addItem(new air.NativeMenuItem("Speicherverzeichnis"));
      temp.keyEquivalent = "v";
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doPref);

      return menu;

      function createHelpMenu(menuType){
      var temp;
      var menu = new air.NativeMenu();
      temp = menu.addItem(new air.NativeMenuItem("Handbuch"));
      temp.keyEquivalent = "h";
      temp.data = menuType;
      temp.addEventListener(air.Event.SELECT, doHelp);

      return menu;

      function noMenu(event){

      in my index.html I call AIRMenus(); in my doLoad()-function.
      has anybody an idea how to control the visibility of menu items?
      thanks in advance.