GUI Commands User GuideVersion 2.1 |
|||||||||||||||||||||||||||||||||||||||||||||||
Face ContextsTo provide greater control over the appearance of buttons and menus GUI Commands allows you to specify faces for different contexts. Commands and groups will then use the best for the button or menu they are creating. Additional contexts are created as per the following example: # configure the default face command@face.text=Default Face # configure the menu face command@face[menu].text=Menu Face Extending Other FacesWhen declaring a face for a particular context you often only need to change a small aspect of an existing face. In this case you can extend other faces and override only the properties that change. The following example creates a toolbar face that inherits from the default face but specifies a larger icon: command@face.text=_Open@default O command@face.icon=classpath:images/file-open.png command@face[toolbar].extends=default command@face[toolbar].icon=classpath:images/file-open-large.png You can also remove properties:
command@face.text=_Open@default O
command@face.icon=classpath:images/file-open.png
# clear the text on the toolbar
command@face[toolbar].extends=default
command@face[toolbar].text=
Note: The above example is only an illustration as you can globally configure
GUI Commands to hide text on toolbars. Please refer to the Renderers
section for more information.
Predefined ContextsThe following lists the contexts that are defined within GUI Commands.
Configuring the Context Search OrderGUI Commands uses a predefined search order to find the best matching face when creating buttons for a specific context. These are only used if there is no face defined for the requested context.
It is possible to configure the search order for any context as shown in the following example. The default face doesn't need to be specified as it is always used as the last option. // Faces created with `myCustomContext` to use the // toolbar, button then default face as a fallback. GuiCommands.defaults().setAlternativeFaceContexts("myCustomContext", Face.TOOLBAR, Face.BUTTON); Setting Popup Face ContextsIn a similar way, you can also configure what face will be used when creating popup menus. A typical
example is when you create a toolbar button from a CommandGroup. In this case the group will use
// Buttons created with `myCustomContext` will use // "myCustomPopupContext" for the popups they create. GuiCommands.defaults().setPopupContext("myCustomContext", "myCustomPopupContext"); |
|||||||||||||||||||||||||||||||||||||||||||||||