Additional top-level classes in compilation unit: PatternActionTemplate, TemplateChain, InputMapTemplateInstance.
InputHandlerTemplate's block of code.
EventPattern matches
InputMap for an explanation. This simply turns that concept into a template that can be used
to add the same InputMap to multiple instances of the same class.
Given a class, the InputMapTemplate code should be created in a static block and then instantiate
itself in the node's constructor:
public class CustomTextField extends TextField {
private final static InputMapTemplate<? super Event> BEHAVIOR;
static {
// creating InputMapTemplates by
InputMapTemplate<CustomTextField, ? extends KeyEvent> keyEventBehavior = sequence(
consume(keyTyped(), (field, event) -> field.setText(event.getText()),
consume(
anyOf(
mousePressed(),
mouseMoved(),
mouseReleased()
),
(field, event) -> field.setText("Mouse event detected! Event: " + event)
)
);
// Other InputMapTemplates (though these don't need to be broken up by
// KeyEvent, MouseEvent, etc. They could be interwoven depending on your desired behavior)
InputMapTemplate<CustomTextField, ? extends MouseEvent> mouseEventBehavior = sequence(
// other InputMapTemplates go here...
);
InputMapTemplate<CustomTextField, ? extends Event> otherCustomEventBehavior = sequence(
// other InputMapTemplates go here...
);
// Tying all of them together into one final InputMapTemplate
BEHAVIOR = sequence(
keyEventBehavior,
mouseEventBehavior,
otherCustomEventBehavior
);
}
public CustomTextField(Object[] args) {
super(args);
// other constructor stuff here
// Install InputMapTemplate onto this node here via one of the two "install" methods
// described after this code block
}
// rest of the class
}
The InputMapTemplate can be instantiated as a default behavior (installFallback(InputMapTemplate, Node)
or as something that overrides prior default behavior (installOverride(InputMapTemplate, Node) (or
their variants). Likewise, it can be removed via uninstall(InputMapTemplate, Node).
| Modifier and Type | Class and Description |
|---|---|
| public static interface |
| Modifier and Type | Field and Description |
|---|---|
| private InputHandlerTemplateMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate | consume(EventPattern<? super T, ? extends U> eventPattern, BiConsumer<? super S, ? super U> action)
If the given |
| public static <S, T extends Event> InputMapTemplate | consume(EventType<? extends T> eventType, BiConsumer<? super S, ? super T> action)
When the given event type occurs, runs the given action, consumes the event,
and does not attempt to match additional |
| public static <S, T extends Event, U extends T> InputMapTemplate | consume(EventPattern<? super T, ? extends U> eventPattern)
If the given |
| public static <S, T extends Event> InputMapTemplate | |
| public static <S, T extends Event, U extends T> InputMapTemplate | consumeUnless(EventPattern<? super T, ? extends U> eventPattern, Predicate<? super S> condition, BiConsumer<? super S, ? super U> action)
If the given |
| public static <S, T extends Event> InputMapTemplate | consumeUnless(EventType<? extends T> eventType, Predicate<? super S> condition, BiConsumer<? super S, ? super T> action)
When the given event type occurs and |
| public static <S, T extends Event, U extends T> InputMapTemplate | consumeWhen(EventPattern<? super T, ? extends U> eventPattern, Predicate<? super S> condition, BiConsumer<? super S, ? super U> action)
If the given |
| public static <S, T extends Event> InputMapTemplate | consumeWhen(EventType<? extends T> eventType, Predicate<? super S> condition, BiConsumer<? super S, ? super T> action)
When the given event type occurs and |
| public final void | |
| protected abstract InputHandlerTemplateMap | |
| public InputMapTemplate | ifConsumed(BiConsumer<? super S, ? super E> postConsumption)
Executes some additional handler if the event was consumed (e.g. |
| public InputMapTemplate | ifIgnored(BiConsumer<? super S, ? super E> postIgnore)
Executes some additional handler if the event was ignored
(e.g. |
| public InputMapTemplate | ifProcessed(BiConsumer<? super S, ? super E> postProceed)
Executes some additional handler if the event was consumed (e.g. |
| public static <S, T extends Event, U extends T> InputMapTemplate | ignore(EventPattern<? super T, ? extends U> eventPattern)
If the given |
| public static <S, T extends Event> InputMapTemplate | |
| public static <S extends Node, E extends Event> void | installFallback(InputMapTemplate<S, E> imt, S node)
Instantiates the input map and installs it into the node via |
| public static <S, N extends Node, E extends Event> void | installFallback(InputMapTemplate<S, E> imt, S target, Function<? super S, ? extends N> getNode)
Instantiates the input map and installs it into the node via |
| public static <S extends Node, E extends Event> void | installOverride(InputMapTemplate<S, E> imt, S node)
Instantiates the input map and installs it into the node via |
| public static <S, N extends Node, E extends Event> void | installOverride(InputMapTemplate<S, E> imt, S target, Function<? super S, ? extends N> getNode)
Instantiates the input map and installs it into the node via |
| public final InputMap | |
| public static <S, T, E extends Event> InputMapTemplate | |
| public final InputMapTemplate | orElse(InputMapTemplate<S, ? extends E> that)
Shorthand for |
| private InputMapTemplate | |
| public static <S, T extends Event, U extends T> InputMapTemplate | process(EventPattern<? super T, ? extends U> eventPattern, BiFunction<? super S, ? super U, InputHandler.
If the given |
| public static <S, T extends Event> InputMapTemplate | process(EventType<? extends T> eventType, BiFunction<? super S, ? super T, InputHandler.
When the given event type occurs, runs the given action, and then attempts
to pattern match the event type with the next |
| public static <S, E extends Event> InputMapTemplate | sequence(InputMapTemplate<S, ? extends E>... templates)
Creates a single InputMapTemplate that pattern matches a given event type against all the given InputMapTemplates. |
| public static <S extends Node, E extends Event> void | uninstall(InputMapTemplate<S, E> imt, S node)
Removes the input map template's instance from the given node. |
| public static <S, N extends Node, E extends Event> void | uninstall(InputMapTemplate<S, E> imt, S target, Function<? super S, ? extends N> getNode)
Removes the input map template's instance from the given node. |
| public static <S, T extends Event> InputMapTemplate | unless(Predicate<? super S> condition, InputMapTemplate<S, T> imt)
When the given |
| pack-priv static <S, E extends Event> InputMapTemplate | |
| public static <S, T extends Event> InputMapTemplate | when(Predicate<? super S> condition, InputMapTemplate<S, T> imt)
When the given |
| inputHandlerTemplates | back to summary |
|---|---|
| private InputHandlerTemplateMap<S, E> inputHandlerTemplates | |
| InputMapTemplate | back to summary |
|---|---|
| public InputMapTemplate() | |
| consume | back to summary |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate If the given | |
| consume | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given event type occurs, runs the given action, consumes the event,
and does not attempt to match additional | |
| consume | back to summary |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate If the given | |
| consume | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given event type occurs, consumes the event and does not attempt
to match additional | |
| consumeUnless | back to summary |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate If the given | |
| consumeUnless | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given event type occurs and | |
| consumeWhen | back to summary |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate If the given | |
| consumeWhen | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given event type occurs and | |
| forEachEventType | back to summary |
|---|---|
| public final void forEachEventType(InputMapTemplate. | |
| getInputHandlerTemplateMap | back to summary |
|---|---|
| protected abstract InputHandlerTemplateMap | |
| ifConsumed | back to summary |
|---|---|
| public InputMapTemplate Executes some additional handler if the event was consumed (e.g. | |
| ifIgnored | back to summary |
|---|---|
| public InputMapTemplate Executes some additional handler if the event was ignored
(e.g. | |
| ifProcessed | back to summary |
|---|---|
| public InputMapTemplate Executes some additional handler if the event was consumed (e.g. | |
| ignore | back to summary |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate If the given | |
| ignore | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given event type occurs, does nothing and does not attempt to match additional
| |
| installFallback | back to summary |
|---|---|
| public static <S extends Node, E extends Event> void installFallback(InputMapTemplate<S, E> imt, S node) Instantiates the input map and installs it into the node via | |
| installFallback | back to summary |
|---|---|
| public static <S, N extends Node, E extends Event> void installFallback(InputMapTemplate<S, E> imt, S target, Function<? super S, ? extends N> getNode) Instantiates the input map and installs it into the node via | |
| installOverride | back to summary |
|---|---|
| public static <S extends Node, E extends Event> void installOverride(InputMapTemplate<S, E> imt, S node) Instantiates the input map and installs it into the node via | |
| installOverride | back to summary |
|---|---|
| public static <S, N extends Node, E extends Event> void installOverride(InputMapTemplate<S, E> imt, S target, Function<? super S, ? extends N> getNode) Instantiates the input map and installs it into the node via | |
| instantiate | back to summary |
|---|---|
| public final InputMap Converts this InputMapTemplate into an | |
| lift | back to summary |
|---|---|
| public static <S, T, E extends Event> InputMapTemplate | |
| orElse | back to summary |
|---|---|
| public final InputMapTemplate Shorthand for | |
| postResult | back to summary |
|---|---|
| private InputMapTemplate | |
| process | back to summary |
|---|---|
| public static <S, T extends Event, U extends T> InputMapTemplate If the given | |
| process | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given event type occurs, runs the given action, and then attempts
to pattern match the event type with the next | |
| sequence | back to summary |
|---|---|
| public static <S, E extends Event> InputMapTemplate Creates a single InputMapTemplate that pattern matches a given event type against all the given InputMapTemplates. This is often the InputMapTemplate installed on a given node since it contains all the other InputMapTemplates.
| |
| uninstall | back to summary |
|---|---|
| public static <S extends Node, E extends Event> void uninstall(InputMapTemplate<S, E> imt, S node) Removes the input map template's instance from the given node. | |
| uninstall | back to summary |
|---|---|
| public static <S, N extends Node, E extends Event> void uninstall(InputMapTemplate<S, E> imt, S target, Function<? super S, ? extends N> getNode) Removes the input map template's instance from the given node. | |
| unless | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given | |
| upCast | back to summary |
|---|---|
| pack-priv static <S, E extends Event> InputMapTemplate | |
| when | back to summary |
|---|---|
| public static <S, T extends Event> InputMapTemplate When the given | |
| Modifier and Type | Method and Description |
|---|---|
| public <F extends E> void | |
| public static <S, E extends Event> InputMapTemplate. |
| accept | back to summary |
|---|---|
| public <F extends E> void accept(EventType<? extends F> t, InputHandlerTemplate<S, ? super F> h) | |
| from | back to summary |
|---|---|
| public static <S, E extends Event> InputMapTemplate. | |