object = DFrame, Bar or BarLayer

object: addButton

DFrame.addButton: Create the default Bar and its default BarLayer if the default Bar if not yet created and create a Button on the default BarLayer of the default Bar.

Bar.addButton: Create a Button on the default BarLayer of the specified Bar.

BarLayer.addButton: Create a Button on the specified BarLayer.

Example

var button = dFrame.addButton('Close', 'dFrame.closeFrame()')

Demos

file: addButton.html

Run the example
See the source code

file: addButtons.html

Run the example
See the source code

Syntaxes

var button = object.addButton(caption, action [, buttonStyle[, position]])

Parameters

caption

String. The text of the Button. The text can use the HTML syntax.

action

String. The Javascript code that will be executed when the Button is activated. See Programming actions for buttons for details about programming those actions.

buttonStyle

ButtonStyle object. The style that will be used to draw the Button. Set buttonStyle to null to use the default ButtonStyle of the Button's parent (Bar or Menu). See default Styles for details.

 position

See position

Return value

button

Button object. The new Button.

Usage

Use this method to add a Button to the default Bar of a DFrame or to a specified Bar.
The addButton method is to be used to create a Button with a background color, a background image, borders and caption. If the whole button is made of an image the addButtonImage is to be used.

The caption is HTML code:

var caption = 'this is a<br><b>button</b>'

is correct.