Class EventManager

  • All Implemented Interfaces:

    
    public final class EventManager
    
                        

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

    • Constructor Detail

      • EventManager

        EventManager(Layout layout, KeyBinder keyBinder, Settings settings)
        Parameters:
        layout - the layout to create this event manager for.
        keyBinder - the key binder to use for this event manager.
      • EventManager

        EventManager(KeyBinder keyBinder, Settings settings)
        Parameters:
        keyBinder - the key binder to use for this event manager.
    • Method Detail

      • isOnMac

         final Boolean isOnMac()

        If the current OS is detected as macOS

      • getMouseDown

         final Boolean getMouseDown()

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

      • setLayout

         final Unit setLayout(Layout layout)
        Parameters:
        layout - the layout to create this event manager for.
      • 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.

      • recalculateMousePos

        @ApiStatus.Internal() final Unit recalculateMousePos()

        Internal function that will force the mouse position to be updated.

        Since:

        0.18.5

      • drop

        @ApiStatus.Internal() final Unit drop(Drawable drawable, Boolean withChildren)

        Internal function that will forcefully drop the given drawable from event tracking.

      • clearModifiers

         final Unit clearModifiers()

        Clear the current keyModifiers.

        Since:

        0.20.1

      • processCandidate

        @ApiStatus.Internal() final Drawable processCandidate(Drawable drawable, Float x, Float y)

        Internal method for drawables, tracking it if it does not consume the events.

        This is used for event dispatching.

      • tryFocus

         final Boolean tryFocus(Drawable drawable)

        try to focus a drawable, and return true if it was successful.

      • dispatch

         final Boolean dispatch(Event event)

        Dispatch an event to this PolyUI instance, and it will be given to any tracked drawable.

      • focus

         final Boolean focus(Focusable focusable)

        Sets the focus to the specified focusable element.

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

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