Class InputManager

  • All Implemented Interfaces:

    
    public final class InputManager
    
                        

    Handles input events and passes them to the correct components/layouts.

    • Constructor Detail

      • InputManager

        InputManager(Inputtable master, KeyBinder keyBinder, Settings settings)
        Parameters:
        master - the layout to create this event manager for.
        keyBinder - the key binder to use for this event manager.
    • Method Detail

      • getDragging

         final Boolean getDragging()

        true if the mouse is currently dragging.

        Since:

        1.6.1

      • getMods

         final Byte getMods()

        the current key modifiers (raw).

      • getMouseDown

         final Boolean getMouseDown()

        weather or not the left button/primary click is DOWN (aka repeating)

      • setKeyBinder

         final Unit setKeyBinder(KeyBinder keyBinder)
        Parameters:
        keyBinder - the key binder to use for this event manager.
      • keyTyped

         final Unit keyTyped(Character key)

        This method should be called when a printable key is typed. This key should be mapped to the user's keyboard layout!

      • keyDown

         final Unit keyDown(Keys key)

        This method should be called when a non-printable, but representable key is pressed.

      • keyDown

         final Unit keyDown(Integer code)

        This method should be called when a non-representable key is pressed.

        This is used solely for keybinding, and so the key can be any value, as long as it is consistent, and unique to that key.

      • keyUp

         final Unit keyUp(Keys key)

        This method should be called when a non-printable, but representable key is released.

      • keyUp

         final Unit keyUp(Integer code)

        This method should be called when a non-representable key is released.

        This is used solely for keybinding, and so the key can be any value, as long as it is consistent, and unique to that key.

      • recalculate

         final Unit recalculate()

        force the mouse position to be updated.

        Since:

        0.18.5

      • drop

        @ApiStatus.Internal() final Unit drop(Inputtable it)

        Drop the current mouse over component.

      • drop

         final Unit drop()

        Synthetically drop all the current input states.

        Useful for some window platforms which don't correctly create release events when the window loses focus.

        Since:

        1.7.4

      • addModifier

         final Unit addModifier(Byte modifier)

        add a modifier to the current keyModifiers.

      • clearModifiers

         final Unit clearModifiers()

        Clear the current keyModifiers.

        Since:

        0.20.1

      • safeFocus

         final Boolean safeFocus(Inputtable component)

        try to focus a component, without throwing an exception.

        Returns:

        true if the component was focused successfully, and false if it is not Inputtable.focusable, or if it is already focused.

        Since:

        1.0.4

      • dispatch

         final Boolean dispatch(Event event, Boolean bindable, Inputtable to)

        Dispatch an event to the provided component.

        If the candidate component does not accept the event (returns false), it will be given to the parent, and so on.

        Note that changing of the to parameter is experimental.

        Parameters:
        bindable - (mostly internal parameter) if true, the event will be given to the keyBinder for processing of keybindings, before being given to the candidate component.
      • focus

         final Boolean focus(Inputtable focusable)

        Sets the focus to the specified focusable element, throwing an exception if the provided element is not focusable.

        Parameters:
        focusable - the element to set focus on
        Returns:

        true if focus was successfully set, false if the provided focusable is already focused