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
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordArguments for aMouseHandler.static final recordResult from aMouseHandler. -
Method Summary
Modifier and TypeMethodDescriptionargsOf(MouseEvent event) ConstructMouseHandler.MouseHandlerArgsfrom aMouseEvent.Handle mouse event wrapped in aMouseHandler.MouseHandlerArgs.static MouseHandlerReturns a handler that always returns a non-consumed result.resultOf(MouseEvent event, boolean consumed, View focus, View capture) default MouseHandlerthenConditionally(MouseHandler other, Predicate<MouseHandler.MouseHandlerResult> predicate) Returns a composed handler that first handlesthishandler and then handlesotherhandler ifpredicateagainst result fromthismatches.default MouseHandlerthenIfConsumed(MouseHandler other) Returns a composed handler that first handlesthishandler and then handlesotherifthisconsumed an event.default MouseHandlerthenIfNotConsumed(MouseHandler other) Returns a composed handler that first handlesthishandler and then handlesotherifthisdid 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 handlesthishandler and then handlesotherhandler ifpredicateagainst result fromthismatches.- 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 handlesthishandler and then handlesotherifthisconsumed an event.- Parameters:
other- the handler to handle after this handler- Returns:
- a composed handler
-
thenIfNotConsumed
Returns a composed handler that first handlesthishandler and then handlesotherifthisdid 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.MouseHandlerArgsfrom 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
-