Class MouseEvent

java.lang.Object
limn.scene.event.InputEvent
limn.scene.event.MouseEvent

public final class MouseEvent extends InputEvent
A pointer event, positioned in scene coordinates (logical points, origin at the window's top-left). Convert to a widget's space with widget.sceneToLocal(event.x(), event.y()). ENTER/EXIT target the hovered leaf and do not bubble; every other type bubbles from the target to its ancestors until consumed.

MOTION is the relative-capture stream: while the window is in PointerMode.RELATIVE, motion arrives as unbounded deltaX()/deltaY() deltas delivered to the focused widget (like keys, since there is no meaningful cursor position to hit-test); x()/y() hold the stale position where the capture began.

The widget a press lands on holds the pointer until it is let go of: the DRAGs and the RELEASE go to it wherever the pointer is. Each of them carries a point of that widget's own plane, so sceneToLocal(x, y) gives it a finite point. Where an ancestor draws the widget in perspective and the pointer goes past the horizon, the scene point has no point on the widget's plane at all; the scene then hands it no DRAG, the widget stays where the pointer last was on its plane, and a RELEASE let go of there arrives at that last point, so a slider commits the value it was showing. The drag goes on when the pointer comes back in front of the horizon. When the plane itself moves while the button is held (a flip under way, a panel or a card turned by the application, past edge-on too), the release arrives where that last point of the widget lies now, or, if that point is now behind the eye, at the nearest point of the widget that can still be seen: that point brought into the widget's box, the press point, its middle or a corner. The one exception is a widget of which nothing can be seen, its plane turned exactly edge-on to the viewer or its whole box behind the eye: the release still arrives, to end the press, at the last scene point, where sceneToLocal answers NaN. Hover events (ENTER, MOVE, EXIT), WHEEL and ZOOM follow the pointer and are not held to this.

ZOOM is a request to zoom around the pointer by scale(): a pinch on a trackpad, and the wheel turned with Command (macOS) or Control held, offered as a zoom before it is a scroll. A widget that zooms consumes it; the rest of that gesture then comes to the same widget, wherever the pointer goes, and a widget that does not zoom lets it bubble, so the wheel goes on as a scroll.

  • Constructor Details

    • MouseEvent

      public MouseEvent(MouseEvent.Type type, float x, float y, int button, float scrollX, float scrollY, int modifiers)
      A pointer event. x and y are in scene coordinates, whichever widget receives it: a widget turns them into its own with sceneToLocal(x, y), which converts the point as a whole.
    • MouseEvent

      public MouseEvent(MouseEvent.Type type, float x, float y, int button, float scrollX, float scrollY, int modifiers, int clickCount)
      A pointer event carrying how many presses in a row this one is.
      Parameters:
      clickCount - 1 for a single press, 2 for the second of a double click, and so on
  • Method Details

    • zoom

      public static MouseEvent zoom(float x, float y, float scale, int modifiers)
      A request to zoom around a point.
      Parameters:
      x - the point, in scene coordinates
      y - the point, in scene coordinates
      scale - what to multiply the present size by: above 1 zooms in, below 1 out
      modifiers - the Keys.MOD_* bits held
      Returns:
      a MouseEvent.Type.ZOOM event
      Throws:
      IllegalArgumentException - if scale is not a positive finite number
    • scale

      public float scale()
      Returns:
      the factor a MouseEvent.Type.ZOOM asks for since the gesture's previous one, above 1 to zoom in and below 1 to zoom out; 1 for every other type
    • clickCount

      public int clickCount()
      Returns:
      how many presses in a row this is — 2 on the second press of a double click — counted with the platform's own double-click interval where the backend knows it, and 1 for anything that is not a press, release or click
    • type

      public MouseEvent.Type type()
      Which pointer transition this is.
    • x

      public float x()
      Returns:
      pointer x in scene coordinates
    • y

      public float y()
      Returns:
      pointer y in scene coordinates
    • button

      public int button()
      Returns:
      the button (Keys.MOUSE_LEFT…), or -1 when not a button event
    • scrollX

      public float scrollX()
      Returns:
      accumulated horizontal wheel delta (WHEEL only)
    • scrollY

      public float scrollY()
      Returns:
      accumulated vertical wheel delta (WHEEL only)
    • deltaX

      public float deltaX()
      Returns:
      accumulated relative horizontal motion in logical points (MOTION only)
    • deltaY

      public float deltaY()
      Returns:
      accumulated relative vertical motion in logical points (MOTION only)
    • modifiers

      public int modifiers()
      Returns:
      modifier bitmask (Keys.MOD_SHIFT…)
    • toString

      public String toString()
      Overrides:
      toString in class Object