Creating Toggle Groups

ToggleGroups allow the combination of ToggleCommands into a mutually exclusive set. The following example demonstrates:

   # Define a mutually exclusive toggle group
   group!align-group@face.text=Text Align
   group!align-group@toggle=true
   group!align-group@exclusive=true
   group!align-group@members=align-left, align-center, align-justify, align-right

You then create and bind a ToggleGroup instance instead of a regular CommandGroup.

   ToggleGroup alignGroup = new ToggleGroup("align-group");
   alignGroup.bind();

Constraints

Once a ToggleCommand is included in a ToggleGroup it can't be added as a direct member to any other group. The typical approach in this case is to add toggle groups to other groups as inline members.

The following shows 3 toggle groups inlined into a toolbar:

Inline Toggle Groups

Empty Selection

It is also possible to have a ToggleGroup that allows the selection to be empty. In this case you specify the property allowEmpty property as true.

   # Define a mutually exclusive toggle group that allows empty selection
   group!align-group@face.text=Text Align
   group!align-group@toggle=true
   group!align-group@exclusive=true
   group!align-group@allowEmpty=true
   group!align-group@members=align-left, align-center, align-justify, align-right

Quaqua Integration

The Quaqua Look and Feel supports Mac specific rendering of toggle buttons that is inline with the Mac OS look and feel guidelines.

GUI Commands defines a specical clientProperty to support rounded toolbars on the Mac. The following example demonstrates:

   # Use rounded toolbar buttons with Quaqua on the Mac
   group!align-group@face.clientProperties[Quaqua.Toolbar.style]=rounded

Please refer to documentation on Mac specific renderers for more information.