EventTypes (e.g. the "case" line in a powerful switch
statement). When match(Event) returns a non-empty Optional, the corresponding
InputHandler will be called.
This class provides a number of static factory methods that provide the base pattern to match.
keyPressed(), keyTyped(),
mousePressed(), mouseClicked(), mouseDragged(), etc.
javafx.scene.input.InputEvent#ANY ), one
will use the base pattern, eventType(EventType)
Once a base pattern is created, one can further define the pattern for which to match for by
adding what are known as "guards" in pattern matching: andThen(EventPattern),
onlyIf(Predicate), unless(Predicate), and anyOf(EventPattern[]). See each
method's javadoc for more info.
// a pattern that matches any key pressed event
keyPressed()
// a pattern that matches only key pressed events where the user
// pressed a digit key
keyPressed().onlyIf(pressedKey -> pressedKey.getCode().isDigitKey())
| Modifier and Type | Field and Description |
|---|---|
| public static final KeyCombination. |
| Modifier and Type | Method and Description |
|---|---|
| public default <V extends U> EventPattern | andThen(EventPattern<? super U, V> next)
Returns an EventPattern that matches the given event type only when this event pattern matches it
and the |
| public static <T extends Event, U extends T> EventPattern | anyOf(EventPattern<T, ? extends U>... events)
Returns an EventPattern that matches the given event type when any of the given EventPatterns match the given event type; useful when one wants to specify the same behavior for a variety of events (i.e. the "copy" action when a user press "CTRL+C" on Windows or "COMMAND+C" on Mac). |
| public static EventPattern | |
| public static <T extends Event> EventPattern | |
| public Set | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | keyPressedNoMod(String character)
Matches the given key pressed event regardless of modifiers; this should only be used for the rare KeyEvents which require a pressed modifier (e.g. Shift) to generate it (e.g. "{"). |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | keyReleasedNoMod(String character)
Matches the given key released event regardless of modifiers; this should only be used for the rare KeyEvents which require a pressed modifier (e.g. Shift) to generate it (e.g. "{"). |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | keyTypedNoMod(String character)
Matches the given key typed event regardless of modifiers; this should only be used for the rare KeyEvents which require a pressed modifier (e.g. Shift) to generate it (e.g. "{"). |
| public Optional | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public static EventPattern | |
| public default EventPattern | |
| public default EventPattern |
| ALL_MODIFIERS_AS_ANY | back to summary |
|---|---|
| public static final KeyCombination. | |
| andThen | back to summary |
|---|---|
| public default <V extends U> EventPattern Returns an EventPattern that matches the given event type only when this event pattern matches it
and the | |
| anyOf | back to summary |
|---|---|
| public static <T extends Event, U extends T> EventPattern Returns an EventPattern that matches the given event type when any of the given EventPatterns match the given event type; useful when one wants to specify the same behavior for a variety of events (i.e. the "copy" action when a user press "CTRL+C" on Windows or "COMMAND+C" on Mac).
| |
| dragDetected | back to summary |
|---|---|
| public static EventPattern | |
| eventType | back to summary |
|---|---|
| public static <T extends Event> EventPattern | |
| getEventTypes | back to summary |
|---|---|
| public Set | |
| keyPressed | back to summary |
|---|---|
| public static EventPattern | |
| keyPressed | back to summary |
|---|---|
| public static EventPattern | |
| keyPressed | back to summary |
|---|---|
| public static EventPattern | |
| keyPressed | back to summary |
|---|---|
| public static EventPattern | |
| keyPressed | back to summary |
|---|---|
| public static EventPattern | |
| keyPressedNoMod | back to summary |
|---|---|
| public static EventPattern Matches the given key pressed event regardless of modifiers; this should only be used for the rare KeyEvents
which require a pressed modifier (e.g. Shift) to generate it (e.g. "{"). If passed in a regular character
(e.g. "a") and this appears before another EventPattern (e.g. keyPressed("a", SHORTCUT_DOWN)) in an
| |
| keyReleased | back to summary |
|---|---|
| public static EventPattern | |
| keyReleased | back to summary |
|---|---|
| public static EventPattern | |
| keyReleased | back to summary |
|---|---|
| public static EventPattern | |
| keyReleased | back to summary |
|---|---|
| public static EventPattern | |
| keyReleased | back to summary |
|---|---|
| public static EventPattern | |
| keyReleasedNoMod | back to summary |
|---|---|
| public static EventPattern Matches the given key released event regardless of modifiers; this should only be used for the rare KeyEvents
which require a pressed modifier (e.g. Shift) to generate it (e.g. "{"). If passed in a regular character
(e.g. "a") and this appears before another EventPattern (e.g. keyReleased("a", SHORTCUT_DOWN)) in an
| |
| keyTyped | back to summary |
|---|---|
| public static EventPattern | |
| keyTyped | back to summary |
|---|---|
| public static EventPattern | |
| keyTyped | back to summary |
|---|---|
| public static EventPattern | |
| keyTypedNoMod | back to summary |
|---|---|
| public static EventPattern Matches the given key typed event regardless of modifiers; this should only be used for the rare KeyEvents
which require a pressed modifier (e.g. Shift) to generate it (e.g. "{"). If passed in a regular character
(e.g. "a") and this appears before another EventPattern (e.g. keyTyped("a", SHORTCUT_DOWN)) in an
| |
| match | back to summary |
|---|---|
| public Optional Returns a non-empty | |
| mouseClicked | back to summary |
|---|---|
| public static EventPattern | |
| mouseClicked | back to summary |
|---|---|
| public static EventPattern | |
| mouseDragged | back to summary |
|---|---|
| public static EventPattern | |
| mouseEntered | back to summary |
|---|---|
| public static EventPattern | |
| mouseEnteredTarget | back to summary |
|---|---|
| public static EventPattern | |
| mouseExited | back to summary |
|---|---|
| public static EventPattern | |
| mouseExitedTarget | back to summary |
|---|---|
| public static EventPattern | |
| mouseMoved | back to summary |
|---|---|
| public static EventPattern | |
| mousePressed | back to summary |
|---|---|
| public static EventPattern | |
| mousePressed | back to summary |
|---|---|
| public static EventPattern | |
| mouseReleased | back to summary |
|---|---|
| public static EventPattern | |
| mouseReleased | back to summary |
|---|---|
| public static EventPattern | |
| onlyIf | back to summary |
|---|---|
| public default EventPattern Returns an EventPattern that matches the given event type only if this event pattern matches it
and the event type passed the given | |
| unless | back to summary |
|---|---|
| public default EventPattern Returns an EventPattern that matches the given event type only if this event pattern matches it
and the event type fails the given | |