## object = DFrame, Bar or BarLayer

## object: addText

Add a text Button on a DFrame, a Bar or a BarLayer.

Demo

file: addText.html

Run the example
See the source code

Many other examples use the addText as a way to comment them. A big text is set in
file: addTaskBarAndMenu.html

Run the example
See the source code

### Syntaxes

object.addText(text[, buttonStyle, [position[, timer]]])

### Parameters

position

See position

Set the position of the text. Array of strings or/and numbers.

2 integer or strings indicating the left and top positions of the text. In percentages of the parent (DFrame or Bar) if numbers, in pixels if strings.

If position = null:

§ DFrame method: Forbidden. The position must be an array of integers or strings

§ Bar or BarLayer method: If set to null the text will be treated as a common Button and aligned and positionned as other Buttons of the Bar.

text

The text to be shown.

buttonStyle

ButtonStyle object. The style that will be used to draw the Button that will contain the text. The ButtonStyle of the DFrame default BarStyle (DFrame.addText) or of the Bar (Bar.addText) will be used if omitted.

Specifications for mouse over or click of the ButtonStyle are inactivated for Buttons created with those methods.

timer

Integer: If set the text will disappear after the time indicated by timer (in seconds) is over.

### Return value

Button object

### Usage

The DFrame.alert or addAlert methods can be used to show a DFrame with text inside. This text will be inserted in scroll boxes and those methods are to be used for big texts.

The addText method is quite different and acts as the DFrame.addButton method:

§ It is to be used for little texts.

§ It does not create the graphical representation of an instantiated DFrame as the alert() method does.

§ It must be used before the DFrame is created.

If the DFrame.addText method is used with a DFrame that will be created with the setURL method the Button will be hidden by the inserted page because it is not protected as a Bar is. This it can be necessary to create a Bar and use the Bar.addText method instead: The Bar will protect the text.

The Buttons created with the addText methods will follow the same rules of position as those applied to Bars: They will be created on the free space remaining after Bars have been created. If you want a text Button to recover the previous created Bars you must use the setOverLayParentBars method.

If autoWidth and/or autoHeight Style properties of the Bar receiving text Buttons are set to 'BUTTON' or 'CONTENT' text Buttons will only be included in the computation of the Bar size if they are added without dimensions i.e as standard Buttons.

Note: If you want to create a text without label in order to set a text in it later and do not want the text to be seen on creation you can use the timer, with a value set to 0: The text will be created and will disappear at once.