Class DragEvent

java.lang.Object
limn.scene.event.DragEvent

public final class DragEvent extends Object
A drag is over a widget. The widget looks at what is offered and where, and calls accept() if it would take it there; it then draws where the drop would land. Saying nothing passes the question to its parent.

A drag driven from the keyboard has no pointer: isKeyboard() is true, the point is the widget's centre the first time, and each arrow key arrives as a stepX() or stepY() that moves the place the widget itself keeps. describePlace(java.lang.String) says that place for a screen reader.

  • Constructor Details

    • DragEvent

      public DragEvent(float x, float y, int modifiers, boolean keyboard, int stepX, int stepY, Offer offer, Set<DropAction> sourceActions, DropAction proposed, @Nullable Object source)
      Parameters:
      x - the pointer, in scene coordinates
      y - the pointer, in scene coordinates
      modifiers - the modifier keys held
      keyboard - whether the keyboard drives the drag
      stepX - -1, 0 or 1: an arrow key pressed in a keyboard drag, in reading order
      stepY - -1, 0 or 1: an arrow key pressed in a keyboard drag
      offer - what is dragged
      sourceActions - what the source allows, its preference first
      proposed - the action the modifier keys ask for, among those
      source - the widget the drag began on, or null when it began in another program
  • Method Details

    • x

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

      public float y()
      Returns:
      the pointer, in scene coordinates
    • modifiers

      public int modifiers()
      Returns:
      the modifier keys held, as Keys.MOD_* bits
    • isKeyboard

      public boolean isKeyboard()
      Returns:
      whether the keyboard drives the drag
    • stepX

      public int stepX()
      Returns:
      -1, 0 or 1: the arrow key pressed, along the line, in a keyboard drag
    • stepY

      public int stepY()
      Returns:
      -1, 0 or 1: the arrow key pressed, across the lines, in a keyboard drag
    • offer

      public Offer offer()
      Returns:
      what is dragged: its formats now, its values at the drop
    • sourceActions

      public Set<DropAction> sourceActions()
      Returns:
      what the source allows, its preference first
    • proposedAction

      public DropAction proposedAction()
      Returns:
      the action the user is asking for: the one the modifier keys name where the source allows it, and otherwise the source's preference
    • source

      public @Nullable Object source()
      Returns:
      the widget the drag began on, or null when it began in another program
    • accept

      public void accept()
      Takes the drop here, with the proposed action.
    • accept

      public void accept(DropAction action)
      Takes the drop here.
      Parameters:
      action - what the drop would do
      Throws:
      IllegalArgumentException - if the source does not allow it
    • isAccepted

      public boolean isAccepted()
      Returns:
      whether a widget accepted
    • acceptedAction

      public @Nullable DropAction acceptedAction()
      Returns:
      the action accepted, or null
    • describePlace

      public void describePlace(String where)
      Says where the drop would land, for a screen reader following a keyboard drag: "before Order 42", "into Customers".
      Parameters:
      where - the place, in the user's language
    • place

      public @Nullable String place()
      Returns:
      the place described, or null