public class ActionList
extends java.lang.Object
A class meant to represent abstract "actions" that can be taken by a user for a given context.
The most common use-case is currently to add ActionList Suppliers to the scene graph, so that all nodes under the mouse cursor can add actions to a right-click event.
The name of an ActionList should be descriptive, as it will be displayed to the user, and reasonably unique within its context--ActionLists with the same name should be combined by the consumer into a single Menu.
Modifier | Constructor and Description |
---|---|
protected |
ActionList(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
static java.util.Optional<ActionList> |
actionsForNode(javafx.scene.Node node)
Retrieves the ActionList supplier that has been added to a node, if one exists.
|
ActionList |
addAction(java.lang.String name,
javafx.scene.Node graphic,
java.lang.Runnable r)
Add an action with an associated graphic, such as a checkmark or icon.
|
ActionList |
addAction(java.lang.String name,
java.lang.Runnable r) |
ActionList |
addNested(ActionList al)
Adds another action list to this one, placing each of its actions in a separate sub-menu.
|
java.lang.String |
getName() |
boolean |
hasItems() |
static void |
registerSupplier(javafx.scene.Node node,
java.util.function.Supplier<ActionList> supplier)
Add an ActionList supplier to a Node, for insertion in a scene graph.
|
java.util.List<javafx.scene.control.MenuItem> |
toMenuItems()
Returns
MenuItem view of the ActionList, with all items represented by either text items or sub-menus. |
static ActionList |
withName(java.lang.String name)
Creates an empty action list with the given name.
|
public boolean hasItems()
public ActionList addAction(java.lang.String name, java.lang.Runnable r)
public ActionList addAction(java.lang.String name, javafx.scene.Node graphic, java.lang.Runnable r)
public java.util.List<javafx.scene.control.MenuItem> toMenuItems()
MenuItem
view of the ActionList, with all items represented by either text items or sub-menus.public ActionList addNested(ActionList al)
For example, adding an action list "C" with actions named "C1" and "C2" to another action list with actions "A" and "B" would look something like this:
- A - B - C - C1 - C2
public java.lang.String getName()
public static ActionList withName(java.lang.String name)
name
- the name of the new action listpublic static void registerSupplier(javafx.scene.Node node, java.util.function.Supplier<ActionList> supplier)
public static java.util.Optional<ActionList> actionsForNode(javafx.scene.Node node)