Interface WindowEventListener

All Known Implementing Classes:
KeyboardHandler, MouseHandler

public interface WindowEventListener
Listens to events on a Window.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    charTyped(Window window, int codePoint, KeyMods mods)
    Called when a character is typed.
    default void
    cursorEntered(Window window, boolean entered)
    Called when the mouse enters or exists the window.
    default void
    filesDropped(Window window, Path... files)
    Called when files are dropped onto the window.
    default void
    focusChanged(Window window, boolean focused)
    Called when the window enters or exits focus.
    default void
    framebufferResized(Window window, int width, int height)
    Called when the window framebuffer is resized.
    default void
    keyPressed(Window window, int key, int scanCode, KeyMods mods)
    Called when a key on the keyboard is pressed.
    default void
    keyReleased(Window window, int key, int scanCode, KeyMods mods)
    Called when a key on the keyboard is released.
    default void
    keyRepeated(Window window, int key, int scanCode, KeyMods mods)
    Called when a key on the keyboard is held util it repeats.
    default void
    mouseMoved(Window window, double x, double y)
    Called when the mouse moves.
    default void
    mousePressed(Window window, int button, KeyMods mods)
    Called when a mouse button is pressed.
    default void
    mouseReleased(Window window, int button, KeyMods mods)
    Called when a mouse button is released.
    default void
    mouseScrolled(Window window, double dx, double dy)
    Called when the mouse wheel is scrolled.
    default void
    Called when the window is closed.
    default void
    windowMoved(Window window, int x, int y)
    Called when the window is moved.
    default void
    windowResized(Window window, int width, int height)
    Called when the window is resized.
  • Method Details

    • windowClosed

      default void windowClosed(Window window)
      Called when the window is closed.
      Parameters:
      window - The window that fired the event
    • windowMoved

      default void windowMoved(Window window, int x, int y)
      Called when the window is moved.
      Parameters:
      window - The window that fired the event
      x - The new x position of the window
      y - The new y position of the window
    • windowResized

      default void windowResized(Window window, int width, int height)
      Called when the window is resized.
      Note: framebufferResized(Window, int, int) should be used to resize rendering.
      Parameters:
      window - The window that fired the event
      width - The new x size of the window
      height - The new y size of the window
    • framebufferResized

      default void framebufferResized(Window window, int width, int height)
      Called when the window framebuffer is resized.
      Parameters:
      window - The window that fired the event
      width - The new x size of the framebuffer
      height - The new y size of the framebuffer
    • focusChanged

      default void focusChanged(Window window, boolean focused)
      Called when the window enters or exits focus.
      Parameters:
      window - The window that fired the event
      focused - Whether the window is now focused
    • filesDropped

      default void filesDropped(Window window, Path... files)
      Called when files are dropped onto the window.
      Parameters:
      window - The window that fired the event
      files - The paths to each file dropped
    • charTyped

      default void charTyped(Window window, int codePoint, KeyMods mods)
      Called when a character is typed.
      Parameters:
      window - The window that fired the event
      codePoint - The code point typed. To get actual chars use Character.toChars(int)
      mods - The keyboard modifier flags set when the key was typed
    • keyPressed

      default void keyPressed(Window window, int key, int scanCode, KeyMods mods)
      Called when a key on the keyboard is pressed.
      Parameters:
      window - The window that fired the event
      key - The universal key code
      scanCode - The machine-specific scan code
      mods - The keyboard modifier flags set when the key was pressed
    • keyReleased

      default void keyReleased(Window window, int key, int scanCode, KeyMods mods)
      Called when a key on the keyboard is released.
      Parameters:
      window - The window that fired the event
      key - The universal key code
      scanCode - The machine-specific scan code
      mods - The keyboard modifier flags set when the key was released
    • keyRepeated

      default void keyRepeated(Window window, int key, int scanCode, KeyMods mods)
      Called when a key on the keyboard is held util it repeats.
      Parameters:
      window - The window that fired the event
      key - The universal key code
      scanCode - The machine-specific scan code
      mods - The keyboard modifier flags set when the key was repeated
    • mouseMoved

      default void mouseMoved(Window window, double x, double y)
      Called when the mouse moves.
      Parameters:
      window - The window that fired the event
      x - The amount the mouse moved in the x
      y - The amount the mouse moved in the y
    • cursorEntered

      default void cursorEntered(Window window, boolean entered)
      Called when the mouse enters or exists the window.
      Parameters:
      window - The window that fired the event
      entered - Whether the cursor entered or left the window
    • mousePressed

      default void mousePressed(Window window, int button, KeyMods mods)
      Called when a mouse button is pressed.
      Parameters:
      window - The window that fired the event
      button - The button that was pressed. Usually one of:
      Standard Mouse Buttons
      MOUSE_BUTTON_LEFT MOUSE_BUTTON_RIGHT MOUSE_BUTTON_MIDDLE
      mods - The keyboard modifier flags set when the mouse button was pressed
    • mouseReleased

      default void mouseReleased(Window window, int button, KeyMods mods)
      Called when a mouse button is released.
      Parameters:
      window - The window that fired the event
      button - The button that was released. Usually one of:
      Standard Mouse Buttons
      MOUSE_BUTTON_LEFT MOUSE_BUTTON_RIGHT MOUSE_BUTTON_MIDDLE
      mods - The keyboard modifier flags set when the mouse button was released
    • mouseScrolled

      default void mouseScrolled(Window window, double dx, double dy)
      Called when the mouse wheel is scrolled.
      Parameters:
      window - The window that fired the event
      dx - The motion in the x. This is for mice that can scroll horizontal as well as vertical
      dy - The motion in the y. This is the standard "mouse wheel" motion