class biz.menu
Contract
Parameter keyDefault valueType
styleoptopt
onloadopttype.<one_of string hypertext.script/>
onunloadopttype.<one_of string hypertext.script/>
onchangeopttype.<one_of string hypertext.script/>
layoutoptlayout
ui_viewopt
accepts_drops_ofoptwob
draggableoptboolean
resizeablefalseboolean
cachetrueboolean
default_show_offtrueboolean
default_show_onfalseboolean
env_or_contextoptwob
Parameter kindDefault valueType
Other unkeyed argumentsopt with ekind of codemenu_item
Water Contract
<class biz.menu
  default_show_off=true=boolean
  default_show_on=false=boolean
  env_or_context=opt=wob
  _other_unkeyed=opt=biz.menu_item="_add_to_environment"
/>

See also: menu_item, biz,

A menu is a collection of menu items, providing dynamic interface behavior and client-to-server communication with AJAX.

Menus may be hierarchical. A menu may contain menu_items, and a menu_item may contain menu_items.

Example 1: Simple menu

This menu has two menu items. They are arranged horizontally. When "QE2" is clicked, it calls method "serve_champagne" on the Water server. When "Titanic" is clicked, it calls method "sink" on the Water server. The upper left corner of this collection of menu items will appear at x,y location 0,0 on the browser.

biz.<menu layout=layout.<row/> >
  biz.<menu_item label="QE2" task=<serve_champagne/> />
  biz.<menu_item label="Titanic" task=<sink/> />
</menu>

Example 2: Hierarchical menu

This menu provides several sub-options for the Titanic. It's arranged in a horizontal row, and sub-options will be arranged in horizontal rows starting below their parent. When the menu first appears it will look like example 1. However, when the user points at "Titanic" with their pointer, its child menu items will appear.

biz.<menu layout=layout.<row/> >
  biz.<menu_item label="QE2" task=<serve_champagne/> />
  biz.<menu_item label="Titanic" task=<sink/> >
    biz.<menu_item label="Drown" task=<drown/> />
    biz.<menu_item label="Take lifeboat" task=<take_lifeboat/> />
    biz.<menu_item label="Sing sappy song" task=<sing/> />
  </menu_item>
</menu>

Using this general pattern, you can construct menus as many levels deep as you want to.

Example 3: Positioning the menu on the page

This is the same as example 1, but is positioned at x,y location 100,200 on the page. The layout will use as its starting location the specified location of the off state of the first menu_item in the menu. If that menu_item does not have a specified location of the off state, as in example 1, the layout uses 0,0 instead.

biz.<menu layout=layout.<row/> >
  biz.<menu_item label="QE2" task=<serve_champagne/> off=<ui_view x=100 y=200/> />
  biz.<menu_item label="Titanic" task=<sink/> />
</menu>

Another way to accomplish this is to specify the origin outright to the layout, as shown here:

biz.<menu layout=layout.<row origin_x=100 origin_y=200/> >
  biz.<menu_item label="QE2" task=<serve_champagne/> />
  biz.<menu_item label="Titanic" task=<sink/> />
</menu>