Class MacDrag
NSDraggingSession
from the window's view, with the pasteboard items a copy would write and the picture the scene
cut for it, and it answers as a dragging destination for whatever is dragged over the view,
from this program or another.
GLFW's content view already is a destination, for file URLs alone and at the drop alone. Its four destination methods are replaced on the class, once, with ours, which ask the window the view belongs to; the view is registered for every kind of data, not only for files.
Everything here runs on the main thread, which is the UI thread. AppKit tracks a drag in a loop of its own, inside the event GLFW was dispatching, as it does a window being resized: the application's loop does not turn until the drag is over, and no frame is produced by it. The destination therefore paints the window itself after each answer, or the widget that accepted would mark where the drop lands and nobody would see it (the owner: the insertion line was gone once the system drove the drag).
Over a place that refuses, the pointer is made the "not allowed" one. AppKit shows nothing for a refusal; the scene's own drag does, and the owner asked for the same here.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Forgets a view that is going away.static MacDraginstall(long view, UiRuntime ui, Supplier<WindowInput> input, Supplier<float[]> pointer, float toScreen, Runnable paint, BooleanSupplier animate, Runnable ownCursor) Makes a window's view a source and a destination of the system's drags.booleanstart(DragRequest request) Begins the system's drag of what the scene asks.
-
Method Details
-
install
public static MacDrag install(long view, UiRuntime ui, Supplier<WindowInput> input, Supplier<float[]> pointer, float toScreen, Runnable paint, BooleanSupplier animate, Runnable ownCursor) Makes a window's view a source and a destination of the system's drags. Main thread.- Parameters:
view- the window's content viewui- the UI runtimeinput- the window's input, as it is at the time of each call; may answer nullpointer- the pointer in the window's logical points, x then ytoScreen- how many of AppKit's points one logical point ispaint- paints the window now, from inside AppKit's own loopanimate- paints the frame the window is waiting for, if any, and says whether it now waits for anotherownCursor- puts the window's own pointer back, once a drag is no longer over it- Returns:
- the window's drag, or null where AppKit would not have it, which is logged
-
close
public void close()Forgets a view that is going away. -
start
Begins the system's drag of what the scene asks. Main thread, while a mouse button is down.- Parameters:
request- what is dragged- Returns:
- whether AppKit took it
-