Commands

open class Commands(val icons: NamedImages?)

A group of many Commands.

Some applications have a single instance of Commands, but more complex application may have many (one for each part of the application).

For shortcuts to work, you must attachTo a node. The shortcuts will only work when the input focus is one of that node's descendants (or itself). Therefore, Scene.root is often a good choice to attach to.

NOTE, button, toggleButton etc. all create Buttons with text as well as a graphic. However, if the Button is placed within a ToolBar, Glok's default theme sets ContentDisplay.GRAPHIC_ONLY, which means that the text will NOT be displayed (assuming the icon exists). If you place the button elsewhere, then the text (and graphic) will be displayed.

(If the graphic is not found, then the button's text is displayed, despite ContentDisplay.GRAPHIC_ONLY).

IMHO, these are the correct defaults, which differ from JavaFX's defaults.

If you prefer JavaFX's defaults, either extend (or replace) Glok's default theme, or set ContentDisplay.LEFT on each toolbar button.

Constructors

Link copied to clipboard
constructor(icons: NamedImages?)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

NOTE, This is a var, which is very unusual! The idea is to let different parts of the GUI use different icon sizes, and yet let them still be adjusted via properties.

Functions

Link copied to clipboard
fun action(action: Action, lambda: (ActionEvent) -> Unit): Command
Link copied to clipboard
fun attachTo(node: Node)

Adds an onKeyPressed event handler to node, which checks the KeyEvent against each action's Action.keyCombination and Action.additionalKeyCombinations.

Link copied to clipboard
fun button(action: Action): Button
fun button(action: Action, block: Button.() -> Unit): Button
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun detachFrom(node: Node)

Removes the key handler added by attachTo.

Link copied to clipboard
fun findCommand(action: Action): Command?
Link copied to clipboard
fun fire(action: Action)

Looks for the command matching action, checks that it isn't disabled, and then calls the Command.lambda.

Link copied to clipboard
operator fun Action.invoke(lambda: (ActionEvent) -> Unit): Command

operator fun Action.invoke(consume: Boolean, lambda: (ActionEvent) -> Unit): Command

Syntactic sugar, which adds an action.

Link copied to clipboard
fun menu(action: Action): Menu
fun menu(action: Action, block: Menu.() -> Unit): Menu
Link copied to clipboard
fun menuButton(action: Action, block: MenuButton.() -> Unit): MenuButton
Link copied to clipboard
fun menuItem(action: Action): MenuItem
fun menuItem(action: Action, block: MenuItem.() -> Unit): MenuItem
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <V, P : Property<V>> radioChoices(property: P, block: PropertyRadioChoicesDSL<V, P>.() -> Unit)
Link copied to clipboard
fun removeAction(action: Action)
Link copied to clipboard
Link copied to clipboard
fun subMenu(action: Action): SubMenu
fun subMenu(action: Action, block: SubMenu.() -> Unit): SubMenu
Link copied to clipboard
fun toggle(action: Action, selected: BooleanProperty): ToggleCommand
fun toggle(action: Action, selected: BooleanProperty, lambda: (ActionEvent) -> Unit): ToggleCommand
Link copied to clipboard
Link copied to clipboard
fun <V, P : Property<V?>> toggleChoices(property: P, block: PropertyToggleChoicesDSL<V, P>.() -> Unit)