Interface WindowInput

All Known Implementing Classes:
SceneDriver

public interface WindowInput
Receives a window's translated native input on the UI thread, in logical points. The backend forwards events as they arrive during the native poll; after each poll (and before draining Ui.post tasks), it calls inputBatchEnded(), which is where the scene dispatches its (coalesced) queue. That yields the deterministic per-frame order: user input → posted tasks → animation → layout → render.

Key codes and the modifier bitmask follow Keys (GLFW-compatible values, but defined by the toolkit; no backend types leak).

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Whether an editing command can be done now by the widget that has the keyboard in this window.
    void
    charTyped(int codepoint)
    Committed text input, one code point (IME/layout-aware, after key events).
    default void
    The drag the system drives left the window, or was called off over it.
    default @Nullable DropAction
    dragOver(Offer offer, Set<DropAction> allowed, float x, float y)
    A drag the system drives is over the window, or moved on it: one begun in another program, or one this window handed over with WindowPeer.startDrag(limn.backend.spi.DragRequest).
    default @Nullable DropAction
    dropped(Offer offer, Set<DropAction> allowed, float x, float y)
    What the system's drag carried is dropped on the window.
    default boolean
    Does an editing command in the widget that has the keyboard in this window.
    default void
    filesDropped(List<Path> paths, float x, float y)
    Files dragged from the OS and dropped on the window, at a point of its content area in logical points: the widget under that point receives them.
    default void
    End of one native poll: dispatch the accumulated batch now.
    default void
    keyEvent(int key, boolean pressed, boolean repeat, int modifiers)
    A key on a US layout, where the key printed on a keycap is the physical key's name: what a test drives.
    void
    keyEvent(int key, int layoutCodePoint, boolean pressed, boolean repeat, int modifiers)
    A key went down, repeated or came up.
    default void
    mouseButton(int button, boolean pressed, int modifiers, float x, float y)
    A press or release the backend did not count: clickCount 0.
    void
    mouseButton(int button, boolean pressed, int modifiers, float x, float y, int clickCount)
    Button press/release at the given cursor position, with how many presses in a row this is, counted by the backend with the platform's own double-click interval and distance: 1 for a single press, 2 for the second of a double click.
    default void
    mouseDelta(float dx, float dy)
    Relative pointer motion while the window is in PointerMode.RELATIVE: unbounded deltas in logical points (raw/unaccelerated where the platform supports it), replacing mouseMoved(float, float) for the duration of the capture.
    void
    mouseMoved(float x, float y)
     
    void
    pointerEntered(boolean entered)
    Cursor entered (true) or left the window's content area.
    default void
    preeditChanged(String text, int caret, int targetStart, int targetLength)
    In-progress IME composition ("preedit") for the focused text input: the still-composing text, its caret, and the stretch of it the input method is converting now (the target the user is choosing a candidate for), shown inline but not yet committed (the commit arrives later via charTyped(int)).
    void
    scrolled(float deltaX, float deltaY, float x, float y)
    Wheel/trackpad scroll; deltas in native notches (positive = up/left).
    default void
    scrolled(float deltaX, float deltaY, float x, float y, boolean gestureBegins)
    A scroll the platform says begins a new gesture: the fingers came down on a trackpad or on a mouse whose surface scrolls, inertia from the gesture before still running or not.
    default void
    The bound window was destroyed.
    default void
    windowFocusChanged(boolean focused)
    The window gained or lost OS input focus.
    default void
    windowFullscreenChanged(boolean fullscreen)
    The window entered (true) or left fullscreen: NativeWindow.isFullscreen() changed its answer.
    void
    windowResized(float logicalWidth, float logicalHeight)
    Window content resized (logical points).
    default void
    zoomed(float scale, float x, float y, boolean gestureBegins)
    A pinch on a trackpad: a request to zoom around the point by a factor.
  • Method Details

    • mouseMoved

      void mouseMoved(float x, float y)
    • mouseDelta

      default void mouseDelta(float dx, float dy)
      Relative pointer motion while the window is in PointerMode.RELATIVE: unbounded deltas in logical points (raw/unaccelerated where the platform supports it), replacing mouseMoved(float, float) for the duration of the capture. The receiver may coalesce by summing. Default: ignored.
    • mouseButton

      void mouseButton(int button, boolean pressed, int modifiers, float x, float y, int clickCount)
      Button press/release at the given cursor position, with how many presses in a row this is, counted by the backend with the platform's own double-click interval and distance: 1 for a single press, 2 for the second of a double click. 0 means the backend does not count, and the receiver counts with its own clock.
    • mouseButton

      default void mouseButton(int button, boolean pressed, int modifiers, float x, float y)
      A press or release the backend did not count: clickCount 0.
    • scrolled

      void scrolled(float deltaX, float deltaY, float x, float y)
      Wheel/trackpad scroll; deltas in native notches (positive = up/left).
    • scrolled

      default void scrolled(float deltaX, float deltaY, float x, float y, boolean gestureBegins)
      A scroll the platform says begins a new gesture: the fingers came down on a trackpad or on a mouse whose surface scrolls, inertia from the gesture before still running or not. A receiver keeps a gesture with the scroller it moved, and only the platform can say where one gesture ends and the next begins while inertia keeps the events coming; a backend that cannot say calls scrolled(float, float, float, float), and the receiver tells gestures apart by the pauses between them.
      Parameters:
      gestureBegins - whether this event is the first of a new gesture
    • zoomed

      default void zoomed(float scale, float x, float y, boolean gestureBegins)
      A pinch on a trackpad: a request to zoom around the point by a factor. The backend turns its system's measure into the factor since its previous event: a magnification added to 1, or this event's scale since the gesture began over the previous one's. A system that sends the pinch as the wheel with Control held needs nothing here; the receiver offers that wheel as a zoom itself. A receiver that takes no zoom ignores it.
      Parameters:
      scale - what to multiply the present size by, positive: above 1 zooms in
      gestureBegins - whether this event is the first of a new pinch
    • keyEvent

      void keyEvent(int key, int layoutCodePoint, boolean pressed, boolean repeat, int modifiers)
      A key went down, repeated or came up.
      Parameters:
      key - the physical key, a Keys constant
      layoutCodePoint - what the active layout types at that key with no modifier held, as a code point, or 0 for a key that types nothing; shortcuts are read from it
      pressed - a press or an auto-repeat rather than a release
      repeat - an auto-repeat
      modifiers - the Keys.MOD_* bits held
    • keyEvent

      default void keyEvent(int key, boolean pressed, boolean repeat, int modifiers)
      A key on a US layout, where the key printed on a keycap is the physical key's name: what a test drives.
    • charTyped

      void charTyped(int codepoint)
      Committed text input, one code point (IME/layout-aware, after key events).
    • preeditChanged

      default void preeditChanged(String text, int caret, int targetStart, int targetLength)
      In-progress IME composition ("preedit") for the focused text input: the still-composing text, its caret, and the stretch of it the input method is converting now (the target the user is choosing a candidate for), shown inline but not yet committed (the commit arrives later via charTyped(int)). An empty text clears the composition. Every index is in code points. Default: ignored.

      What it means, rather than one platform's shape of it: GLFW reports styled blocks and the focused one, SDL a string and a selection; a backend turns either into the target's start and length.

      Parameters:
      text - the composing text ("" clears it)
      caret - caret position within text
      targetStart - where the stretch being converted starts within text
      targetLength - how long it is; 0 when nothing is being converted
    • pointerEntered

      void pointerEntered(boolean entered)
      Cursor entered (true) or left the window's content area.
    • windowResized

      void windowResized(float logicalWidth, float logicalHeight)
      Window content resized (logical points). May be coalesced by the receiver.
    • dragOver

      default @Nullable DropAction dragOver(Offer offer, Set<DropAction> allowed, float x, float y)
      A drag the system drives is over the window, or moved on it: one begun in another program, or one this window handed over with WindowPeer.startDrag(limn.backend.spi.DragRequest). Answered at once, since the system waits for the answer to show whether a drop is possible there.
      Parameters:
      offer - what is dragged: its formats now, its values at the drop
      allowed - what the source allows with the modifier keys as they are held, the source's preference first
      x - the pointer, in logical points
      y - the pointer, in logical points
      Returns:
      the action a widget there would carry out, or null when none takes it
    • dragLeft

      default void dragLeft()
      The drag the system drives left the window, or was called off over it. Default: ignored.
    • dropped

      default @Nullable DropAction dropped(Offer offer, Set<DropAction> allowed, float x, float y)
      What the system's drag carried is dropped on the window. The values of offer can be read now and for as long as the offer is kept.
      Parameters:
      offer - what was dragged
      allowed - what the source allows, as for dragOver(limn.transfer.Offer, java.util.Set<limn.transfer.DropAction>, float, float)
      x - the pointer, in logical points
      y - the pointer, in logical points
      Returns:
      the action a widget carried out, or null when none took it
    • filesDropped

      default void filesDropped(List<Path> paths, float x, float y)
      Files dragged from the OS and dropped on the window, at a point of its content area in logical points: the widget under that point receives them. The point is the platform's where it says one (SDL does), and the pointer's at the drop where it does not (GLFW). Default: ignored.
      Parameters:
      paths - the files, in the order the platform listed them
      x - where they were dropped, in logical points
      y - where they were dropped, in logical points
    • windowFocusChanged

      default void windowFocusChanged(boolean focused)
      The window gained or lost OS input focus. On loss the scene cancels any in-flight press/drag/hover; the matching RELEASE will never arrive (it happens in another app), so it is synthesized. Default: ignored.
    • windowFullscreenChanged

      default void windowFullscreenChanged(boolean fullscreen)
      The window entered (true) or left fullscreen: NativeWindow.isFullscreen() changed its answer. Every change is told once, whoever made it: the application's enterFullscreen and exitFullscreen, and on macOS the person's green button, Control-Command-F or menu item. It is told when the answer changes, which for macOS native fullscreen is when the animation starts rather than when it ends. On the scene it closes a menu, a drop-down list or a calendar that is open in a window of its own, placed against the geometry the change is taking away, and moves a modal dialog's window into the scene.

      Told even while a modal blocks the window, as a focus change is: the dialog that blocks it is one of the surfaces that has to hear it. Arrives during the native poll, or from inside the call that changed fullscreen, and like the rest of the batch it is acted on when the batch ends. Default: ignored.

    • inputBatchEnded

      default void inputBatchEnded()
      End of one native poll: dispatch the accumulated batch now.
    • windowClosed

      default void windowClosed()
      The bound window was destroyed. Lets the receiver flush any work that was waiting on a future frame which will now never come, chiefly a window-fade arrival callback (e.g. a dialog completing its result after fading out), since a destroyed window never ticks again. UI thread.
    • canEditFocused

      default boolean canEditFocused(EditCommand command)
      Whether an editing command can be done now by the widget that has the keyboard in this window. Asked for a row of a menu the system draws that is an editing command.
    • editFocused

      default boolean editFocused(EditCommand command)
      Does an editing command in the widget that has the keyboard in this window.
      Returns:
      whether a widget did it