MenuBar and MenuItem
This example will show you how to create Horizontal and vertical Menu Bar and add Items to these menu bar.
References:
http://code.google.com/googleapps/appsscript/class_menubar.html
http://code.google.com/googleapps/appsscript/class_menuitem.html
http://code.google.com/googleapps/appsscript/class_menuitemseparator.html
Demo screenShots:
Example Code:
function doGet(e) {
var app = UiApp.createApplication();
//Create menu bar
//var menuBar = app.createMenuBar(true);// For vertical menuBar
var menuBar = app.createMenuBar();//For horizontal menubar
//Create a handler.. you can create separate handler for each menuItem
var handler = app.createServerHandler();
//top level menu items
var menuItem0 = app.createMenuItem('MenuItem0', handler);
var menuItem1 = app.createMenuItem('MenuItem1', handler);
var menuItem2 = app.createMenuItem('MenuItem2', handler);
var menuItem3 = app.createMenuItem('MenuItem3', handler);
//create menuItem separators
var separator0 = app.createMenuItemSeparator();
var separator1 = app.createMenuItemSeparator();
var separator2 = app.createMenuItemSeparator();
var separator3 = app.createMenuItemSeparator();
var separator4 = app.createMenuItemSeparator();
//Add the menu item separators and menuItem to the MenuBar
menuBar.addSeparator(separator0).addItem(menuItem0).addSeparator(separator1)
.addItem(menuItem1).addSeparator(separator2)
.addItem(menuItem2).addSeparator(separator3)
.addItem(menuItem3).addSeparator(separator4);
app.add(menuBar);
return app;
}
KeyWords:
Horizontal Menu Bar, Vertical Menu Bar, Menu bar using apps script, Google Apps Script Menu Bar