Interface MouseHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Handles mouse events in a form of
MouseHandler.MouseHandlerArgs
and returns
MouseHandler.MouseHandlerResult
. Typically used in a View
.
MouseHandler
itself don't define any restrictions how it's used.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final record
Arguments for aMouseHandler
.static final record
Result from aMouseHandler
. -
Method Summary
Modifier and TypeMethodDescriptionargsOf
(MouseEvent event) ConstructMouseHandler.MouseHandlerArgs
from aMouseEvent
.Handle mouse event wrapped in aMouseHandler.MouseHandlerArgs
.static MouseHandler
Returns a handler that always returns a non-consumed result.resultOf
(MouseEvent event, boolean consumed, View focus, View capture) default MouseHandler
thenConditionally
(MouseHandler other, Predicate<MouseHandler.MouseHandlerResult> predicate) Returns a composed handler that first handlesthis
handler and then handlesother
handler ifpredicate
against result fromthis
matches.default MouseHandler
thenIfConsumed
(MouseHandler other) Returns a composed handler that first handlesthis
handler and then handlesother
ifthis
consumed an event.default MouseHandler
thenIfNotConsumed
(MouseHandler other) Returns a composed handler that first handlesthis
handler and then handlesother
ifthis
did not consume an event.
-
Method Details
-
handle
Handle mouse event wrapped in aMouseHandler.MouseHandlerArgs
.- Parameters:
args
- the mouse handler arguments- Returns:
- a handler result
-
thenConditionally
default MouseHandler thenConditionally(MouseHandler other, Predicate<MouseHandler.MouseHandlerResult> 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
ConstructMouseHandler.MouseHandlerArgs
from aMouseEvent
.- Parameters:
event
- the mouse event- Returns:
- a mouse handler args
-
resultOf
static MouseHandler.MouseHandlerResult resultOf(MouseEvent event, boolean consumed, View focus, View capture) - Parameters:
event
- the mouse eventconsumed
- flag telling if event was consumedfocus
- the view which is requesting focuscapture
- the view which captured an event- Returns:
- a mouse handler result
-