ButtonBar
A horizontal container primarily for buttons. The order of the buttons matches the platform's standard, and not the order the buttons were added. For example, the buttons OK
, Cancel
, Apply
appear in these orders :
Windows :
OK
,Cancel
,Apply
MacOs :
Cancel
,OK
,Apply
Linux (Gnome) :
Apply
,Cancel
,OK
The order of the buttons is governed by buttonOrder. This is a string, where each character is the code of a ButtonMeaning. The default value is dependent on the platform. See defaultOrder.
You assign a meaning to each button either by adding buttons using the special add method, or by adding nodes to items as usual, and then calling meaningOf. If no meaning is specified, then it is assumed to be ButtonMeaning.OTHER.
Scene Graph DSL
buttonBar {
add(ButtonMeaning.OK) {
button( "OK" ) { onAction { ... } }
}
add(ButtonMeaning.CANCEL) {
button( "Cancel" ) { onAction { ... } }
}
}
Theme DSL
"button_bar" {
buttonOrder( string )
fillHeight( boolean )
spacing( number ) // A feature of BoxBase, not ButtonBar itself, but included here anyway.
child(BUTTON_BAR_SECTION) {
spacing( number ) // Should be the same as button_bar's spacing.
child(BUTTON) {
minWidth( number ) // minWidth is a feature common to all nodes.
}
}
}
ButtonBar and each section inherit all the features of BoxBase.
Differences from JavaFX.
There is no
buttonMinWidth
. Instead, the theme should include a rule such as : "button_bar" { child( "button" ) { minWidth( 100 ) } }ButtonMeaning is the equivalent of JavaFX's
ButtonBar.ButtonData
. IMHO, their name is bad, and using an inner class makes code verbose, and hard to read.Glok has two defaults for linux. See defaultOrder.
The default order can be set using an environment variable. See defaultOrder.
Properties
The base class Node has no children, so this is an empty list.
Functions
If you add nodes directly via children, then you should also specify their meaning, via this function. Otherwise, the nodes are assumed to be ButtonMeaning.OTHER, and won't be positioned as you (or the users) might like.