Command

open class Command(val action: Action, val lambda: (ActionEvent) -> Unit?)

A Command defines what should happen when a GUI element is pressed, without being associated with a particular node.

This means that a single Command can be used by more than one Node. For example, an 'Undo' button in a ToolBar can use the same Action as an 'Undo' menu item in a Menu.

The DRY principal (Don't Repeat Yourself).

In a 'traditional' application, DRY is achieved by calling an 'undo()' method from the onAction event of the Undo Button, and the Undo MenuItem. However, this means that when we build our scene graphs, we would need to reference the classes that perform the action, and in a large application, this can get messy.

Instead, we define the Commands completely separately from the Actions.

Commands are found into the Commands class, and Actions with the Actions class.

FYI. This was named Command after the Gang of Four's Design Patterns book.

Inheritors

Constructors

Link copied to clipboard
constructor(action: Action, lambda: (ActionEvent) -> Unit?)

Properties

Link copied to clipboard
Link copied to clipboard

Should this command consume the event, which prevents other event handlers firing?

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String