Interface KeyHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Handles Key events in a form of
KeyHandler.KeyHandlerArgs
and returns
KeyHandler.KeyHandlerResult
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final record
Arguments for aKeyHandler
.static final record
Result from aKeyHandler
. -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyHandler.KeyHandlerArgs
ConstructKeyHandler.KeyHandlerArgs
from aKeyEvent
.Handle Key event wrapped in aKeyHandler.KeyHandlerArgs
.static KeyHandler
Returns a handler that always returns a non-consumed result.static KeyHandler.KeyHandlerResult
default KeyHandler
thenConditionally
(KeyHandler other, Predicate<KeyHandler.KeyHandlerResult> predicate) Returns a composed handler that first handlesthis
handler and then handlesother
handler ifpredicate
against result fromthis
matches.default KeyHandler
thenIfConsumed
(KeyHandler other) Returns a composed handler that first handlesthis
handler and then handlesother
ifthis
consumed an event.default KeyHandler
thenIfNotConsumed
(KeyHandler other) Returns a composed handler that first handlesthis
handler and then handlesother
ifthis
did not consume an event.
-
Method Details
-
handle
Handle Key event wrapped in aKeyHandler.KeyHandlerArgs
.- Parameters:
args
- the Key handler arguments- Returns:
- a handler result
-
thenConditionally
default KeyHandler thenConditionally(KeyHandler other, Predicate<KeyHandler.KeyHandlerResult> predicate) Returns a composed handler that first handlesthis
handler and then handlesother
handler ifpredicate
against result fromthis
matches.- Parameters:
other
- the handler to handle after this handlerpredicate
- the predicate test against results from this- Returns:
- a composed handler
-
thenIfConsumed
Returns a composed handler that first handlesthis
handler and then handlesother
ifthis
consumed an event.- Parameters:
other
- the handler to handle after this handler- Returns:
- a composed handler
-
thenIfNotConsumed
Returns a composed handler that first handlesthis
handler and then handlesother
ifthis
did not consume an event.- Parameters:
other
- the handler to handle after this handler- Returns:
- a composed handler
-
neverConsume
Returns a handler that always returns a non-consumed result.- Returns:
- a handler that always returns a non-consumed result
-
argsOf
ConstructKeyHandler.KeyHandlerArgs
from aKeyEvent
.- Parameters:
event
- the Key event- Returns:
- a Key handler args
-
resultOf
- Parameters:
event
- the Key eventfocus
- the view- Returns:
- a Key handler result
-