Next: Make a menu with a submenu

Make a menu with a submenu



 function doGet(e)   
 {  
  var app = UiApp.createApplication();  
  var fooMenu = app.createMenuBar().setId('menu');    
  var fooMenuVertical = app.createMenuBar(true);  
  var handlerEdit = app.createServerClickHandler('showEdit');  
  var handlerView = app.createServerClickHandler('showView');  
  var handlerFile1 = app.createServerClickHandler('showFile1');  
  var handlerFile2 = app.createServerClickHandler('showFile2');  
  var handlerFile3 = app.createServerClickHandler('showFile3');  
  fooMenuVertical.addItem('SubFile1', handlerFile1)  
  fooMenuVertical.addItem('SubFile2', handlerFile2);  
  fooMenuVertical.addItem('SubFile3', handlerFile3);   
  fooMenu.addItem('File', fooMenuVertical)  
  fooMenu.addItem('Edit', handlerEdit);  
  fooMenu.addItem('View', handlerView).setId('prova');  
  fooMenu.addSeparator();   
  var label = app.createLabel('Item: ').setId('myLabel');  
  app.add(fooMenu);  
  app.add(label);  
  return app;   
 }  
 function showEdit(e)  
 {  
    var app = UiApp.getActiveApplication();  
    app.getElementById('myLabel').setText('Edit');  
    return app;   
 };  
 function showView(e)  
 {  
    var app = UiApp.getActiveApplication();  
    app.getElementById('myLabel').setText('View');  
    return app;   
 };  
 function showFile1(e)  
 {  
    var app = UiApp.getActiveApplication();  
    app.getElementById('myLabel').setText('File1');  
    return app;   
 };  
 function showFile2(e)  
 {  
    var app = UiApp.getActiveApplication();  
    app.getElementById('myLabel').setText('File2');  
    return app;   
 };  
 function showFile3(e)  
 {  
    var app = UiApp.getActiveApplication();  
    app.getElementById('myLabel').setText('File3');  
    return app;   
 };