ButtonStyle : setLabelHAlign

ButtonStyle : setLabelVAlign

 

ButtonStyle : setLabelTopMargin

ButtonStyle : setLabelBottomMargin

ButtonStyle : setLabelLeftMargin

ButtonStyle : setLabelRightMargin

 

Set the position of label of Buttons and the margins between labels and borders of buttons.

setLabelHAlign, setLabelRightMargin and setLabelLeftMargin: Horizontal position.

setLabelVAlign, setLabelTopMargin and setLabelBottomMargin: Vertical position.

Demo

file: setLabelHAlign.html

Run the example
See the source code

Syntaxes

ButtonStyle.setLabelHAlign(string)

ButtonStyle.setLabelLeftMargin(number)

ButtonStyle.setLabelRightMargin(number)

ButtonStyle.setLabelVAlign(string)

ButtonStyle.setLabelTopMargin(number)

ButtonStyle.setLabelBottomMargin(number)

Parameters

number

setLabelXXXMargin methods (XXX=Top, Right, Bottom or Left). Integer. The number of pixels between the border and the label.

string

setLabelHAlign and setLabelVAlign methods. Keyword (not case sensitive).

'LEFT', 'RIGHT' or 'CENTER' for setLabelHAlign

'TOP', 'BOTTOM' or 'CENTER' for setLabelVAlign

Usage

Those 6 methods will have different results depending on the way the width/height of the Button is computed:

if setAutoWidth('LABEL')

If the width of the Button is determined by the setAutoWidth('LABEL') method the width of the Button will be:

label width

+ borderLeftWidth + borderRightWidth

+ labelLeftMargin + labelRightMargin

and the position of the label inside the button will depend on the labelHAlign values: If this value

§         is set to 'LEFT', RIGHT or '' (empty string) the label will be aligned with the labelLeftMargin and labelRightMargin values.

§         is set to 'CENTER the label will be centered even labelLeftMargin and labelRightMargin are different. The left and right margins will be (labelLeftMargin + labelRightMargin) / 2

Same / symmetric for the height of the button.

else, if setAutoWidth('IMAGE'), setAutoWidth('LARGEST')  or setAutoWidth(')

If the width of the button is not determined by the setAutoWidth('LABEL') but setWidth, setAutoWidth('IMAGE') or setAutoWidth('LARGEST') the width of the Button will be larger than the width of the label.

In this case

§         the alignment of the label is determined by the labelHAlign value.

§         labelLeftMargin will be used for the left margin if labelHAlign is set to 'LEFT' (and labelRightMargin ignored) and labelRightMargin for the right margin if labelHAlign is set to 'RIGHT' (labelLeftMargin ignored).

Same / symmetric for the vertical alignment and margins of the button.

Default values:

The labelLeftMargin, labelRightMargin, topMargin and bottomMargin are both set to 5.