buttonsArrayDefinition

3 methods use the buttonArrayDefinition as parameter:

DFrame, Bar and BarLayer: addButtons

DFrame, Bar and BarLayer: addMenu

DFrame: addContextMenu

The buttonArrayDefinitions is an array of arrays.

This document explains how to define those buttonsArrayDefinitions.

Example:

//Define buttonsArrayDefinition for a sub Menu

subMenuDef = new Array()

subMenuDef[0] = new Array('Button', 'New', 'alert("Click !")')

subMenuDef[1] = new Array('Button', 'Open', 'alert("Click !")')

                  

//Define buttonsArrayDefinition for the main menu

var menuDef = new Array()

menuDef[0] = new Array('Button', 'Documents', subMenuDef)

menuDef[1] = new Array('Button', 'Exit', 'thisDFrame.closeFrame()')

Demo

file: addMenu-1.html

Run the example
See the source code

buttonsArrayDefinition

Array of arrays: Each item of the array defines a Button or an item of a Menu (which is a Button) and is itself an array:
[itemType, caption, action, buttonStyle, position] to define items as Buttons.
or
[itemType,
action, preloadedImage, position] to define items as ButtonImages.

itemType

The first item of the array is a keyword that defines the type of the Menu item.

§         To define an item as a Button: ['BUTTON', caption, action, buttonStyle, position]

§         To define an item as a buttonImage: ['BUTTONIMAGE', action,  preloadedImage, position]

caption

Button items only (no caption for ButtonImage items). String. The text of the Button.

action

For Button and ButtonImage items: String. The Javascript code that will be executed when the Button is activated. See Programming actions for buttons for details about programming those actions.
To define a sub-menu: Array defining the sub-menu. This array follows the rules of the buttonArrayDefinition

buttonStyle

Button items only (no Style for ButtonImage items). ButtonStyle object. The style that will be used to draw the item. Set buttonStyle to null to use the default ButtonStyle property of the styles of the Button's parent (BarStyle.defaultButtonStyle) or of the Menu.

preloadedImage

ButtonImage items only (Button items can have images but they are set in the ButtonStyle properties) The name of a set of images preloaded with the DFrameAPI.preLoadImagesForButtonImage().

position

See position of objects.