## ButtonStyle: setPos

## ButtonStyle : setWidth

## ButtonStyle : setAutoWidth

## ButtonStyle : setHeight

## ButtonStyle : setAutoHeight

ButtonStyle: setPos. Define the position of the Button.

ButtonStyle.setWidth. Set the width of the Button, or the minimal width if setAutoWidth() is used with a parameter.

ButtonStyle.setAutoWidth: Indicates that the width will be adjusted to the width of the text or of the image of the Button.

ButtonStyle.setHeight. Set the height of the Button, or the minimal height if setAutoHeight() is used with a parameter.

ButtonStyle.setAutoHeight. Indicates that the width will be adjusted to the width of the text or of the image of the Button

Example

var buttonStyle = new ButtonStyle()

buttonStyle.setWidth(100)

buttonStyle.setAutoWidth('LABEL')

Demo

This demo demonstrates the setWidth method used in conjunction with the setAutoWidth method.

file: setAutoWidthForButtons.html

Run the example
See the source code

Syntaxes

ButtonStyle.setPos(position)

ButtonStyle. setWidth(number)

ButtonStyle. setAutoWidth(stringKeyword)

ButtonStyle. setHeight(number)

ButtonStyle. setAutoHeight(stringKeyword)

### Parameters

position

setPos method. Array of 2 or 4 values. Indicates coordinates and dimensions of the Button on a Bar.

Coordinates are in % of the Bar's size if numbers, in pixels if strings. The '*' value allow a centered position.

See position in Reference documentation for more information.

number

setWidth and setHeight methods. Integer. The width of Button

stringKeyword

setAutoWidth and setAutoHeight methods . String (not case sensitive):

§ '' (empty string). The width/height of Buttons will be those defined with the setWidth/Height methods.

§ 'LABEL': Set the width/height of the Button to the width/height of its label.

§ 'IMAGE': Set the width/height of the Button to the width/height of the image defined by setImageXXX methods.

§ 'LARGEST': First set the width/height of the Button to the width/height of its label. Then set the width/height of the Button to the width/height of the largest Button of the same bar for a Button or Menu for a Menu item.

§ 'MENU: Only for Buttons used as items of Menus. Set the width of the button to the width of the Menu. See the setAutoWidth method of MenuStyle.

### Usage

If the button contains a arrow image (setImageArrow method of Menu for items of menus having a sub-menu) or a close image (setImageClose method of Button, mainly used for Buttons of task Bars) the width of Buttons is enlarged of the size of those images.

Caution 1: If, for instance, you set up a Style for a standard Button, set a width and then use this Style as a default ButtonStyle the width you set will, of course, apply:

var buttonStyle = new ButtonStyle()

buttonStyle.setWidth(80)

barStyle.setDefaultBarStyle(barStyle)

…

var buttonStyleForTaskBar = new ButtonStyle(buttonStyle)

buttonStyleForTaskBar.setImageNormal(urlForImage)

buttonStyleForTaskBar.setAutoWidth('IMAGE')

You will get a button with a minimal width of 80, unless you reset the width to 0:

buttonStyleForTaskBar.setWidth(0)

Caution 2: The borders of Buttons always exist if a width different from 0 is set, even if the setBordersXXX (setBordersNormal, setBordersRoll etc …) are set to false. If you use an image and the setAutoWidth('IMAGE') the width of the Button will be the width of the image + the width of the borders.

On the contrary if you want a Button to have a certain width/height you must use the setWidth/Height methods AND set the autoWidth/Height to '' (empty string) as the default value is 'LABEL'.

Note that the setPos values will be overwritten by the position parameter if set in the instantiation of the object.