Interface MouseInteractionController

All Known Implementing Classes:
GuiComponent, TextEditComponent

public interface MouseInteractionController
Interface that allows to handle mouse events.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    mouseClicked(int button)
    Called when mouse is clicked on component.
    default boolean
    mouseClicked(int button, double textureU, double textureV)
    Called when mouse is clicked on component, with the exact texture coordinates of the clicked point when the hit shape is textured.
    default boolean
    mouseClicked(int button, double textureU, double textureV, KeyboardFocusStack focusStack)
    Called when mouse is clicked on component, additionally carrying the keyboard focus stack of the dispatching view.
    boolean
    Called when mouse gets over given component.
    boolean
    Called when mouse leaves screen area occupied by component.
    default boolean
    mouseHover(double textureU, double textureV)
    Called when the mouse hovers over this component, with the exact texture coordinates of the hovered point when the hit shape is textured (NaN otherwise).
    default boolean
    mouseWheelMoved(int verticalUnits, int horizontalUnits)
    Called when the mouse wheel is turned while this component has keyboard focus.
  • Method Details

    • mouseClicked

      boolean mouseClicked(int button)
      Called when mouse is clicked on component.
      Parameters:
      button - the mouse button that was clicked (1 = left, 2 = middle, 3 = right)
      Returns:
      true if view update is needed as a consequence of this mouse click
    • mouseClicked

      default boolean mouseClicked(int button, double textureU, double textureV)
      Called when mouse is clicked on component, with the exact texture coordinates of the clicked point when the hit shape is textured.

      The default implementation ignores the texture coordinates and delegates to mouseClicked(int). Components that need to know WHERE on their surface the click landed (e.g. to forward the click into a captured application window) override this method.

      Parameters:
      button - the mouse button that was clicked (1 = left, 2 = middle, 3 = right)
      textureU - texture-space X of the clicked point in primary-texture pixels, or Double.NaN when the hit shape has no texture
      textureV - texture-space Y of the clicked point in primary-texture pixels, or Double.NaN when the hit shape has no texture
      Returns:
      true if view update is needed as a consequence of this mouse click
    • mouseClicked

      default boolean mouseClicked(int button, double textureU, double textureV, KeyboardFocusStack focusStack)
      Called when mouse is clicked on component, additionally carrying the keyboard focus stack of the dispatching view.

      Components that take keyboard focus on click should override THIS method rather than reaching for a stored ViewPanel reference: scenes built headlessly (golden-image harness) construct components with a null panel, but the dispatching view always has a focus stack.

      The default implementation ignores the focus stack and delegates to mouseClicked(int, double, double).

      Parameters:
      button - the mouse button that was clicked (1 = left, 2 = middle, 3 = right)
      textureU - texture-space X of the clicked point, or Double.NaN
      textureV - texture-space Y of the clicked point, or Double.NaN
      focusStack - keyboard focus stack of the dispatching view
      Returns:
      true if view update is needed as a consequence of this mouse click
    • mouseWheelMoved

      default boolean mouseWheelMoved(int verticalUnits, int horizontalUnits)
      Called when the mouse wheel is turned while this component has keyboard focus. Both axes are reported: horizontal wheel input arrives from AWT as shift-modified vertical rotation and is separated by the input manager.

      Returning false lets the wheel fall through to the default camera movement.

      Parameters:
      verticalUnits - wheel notches; positive = wheel away from the user (content scrolls down)
      horizontalUnits - wheel notches; positive = scroll right
      Returns:
      true if the component consumed the scroll
    • mouseHover

      default boolean mouseHover(double textureU, double textureV)
      Called when the mouse hovers over this component, with the exact texture coordinates of the hovered point when the hit shape is textured (NaN otherwise). Allows components that forward input into a captured application window to track the pointer position.
      Returns:
      true if view update is needed
    • mouseEntered

      boolean mouseEntered()
      Called when mouse gets over given component.
      Returns:
      true if view update is needed as a consequence of this mouse enter.
    • mouseExited

      boolean mouseExited()
      Called when mouse leaves screen area occupied by component.
      Returns:
      true if view update is needed as a consequence of this mouse exit.