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.

@FunctionalInterface public interface KeyHandler
Handles Key events in a form of KeyHandler.KeyHandlerArgs and returns KeyHandler.KeyHandlerResult.
  • Method Details

    • handle

      Handle Key event wrapped in a KeyHandler.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 handles this handler and then handles other handler if predicate against result from this matches.
      Parameters:
      other - the handler to handle after this handler
      predicate - the predicate test against results from this
      Returns:
      a composed handler
    • thenIfConsumed

      default KeyHandler thenIfConsumed(KeyHandler other)
      Returns a composed handler that first handles this handler and then handles other if this consumed an event.
      Parameters:
      other - the handler to handle after this handler
      Returns:
      a composed handler
    • thenIfNotConsumed

      default KeyHandler thenIfNotConsumed(KeyHandler other)
      Returns a composed handler that first handles this handler and then handles other if this did not consume an event.
      Parameters:
      other - the handler to handle after this handler
      Returns:
      a composed handler
    • neverConsume

      static KeyHandler neverConsume()
      Returns a handler that always returns a non-consumed result.
      Returns:
      a handler that always returns a non-consumed result
    • argsOf

      static KeyHandler.KeyHandlerArgs argsOf(KeyEvent event)
      Parameters:
      event - the Key event
      Returns:
      a Key handler args
    • resultOf

      static KeyHandler.KeyHandlerResult resultOf(KeyEvent event, boolean consumed, View focus)
      Construct KeyHandler.KeyHandlerResult from a KeyEvent and a View.
      Parameters:
      event - the Key event
      focus - the view
      Returns:
      a Key handler result