'Detect file drag'n'drop events in JOGL/NEWT GLWindow
The GLWindow provides methods to add callback listeners for mouse events, key events and window events (such as resize events), but how can we detect file drag-and-drop events, akin to the java.awt DropTarget?
The motivation here is to handle drag-and-drop events in Processing using its JOGL-based rendering modes (P2D and P3D), which automatically create a GLWindow for the sketch to run in.
Under NEWT Usage:
NewtCanvasAWT, representing an AWT Canvas, allows you to hook a NEWT Window into it.
I have tried the following, although I don't know whether this should work. Either way, it isn't.
var window = new NewtCanvasAWT(glWindow);
window.setDropTarget(new DropTarget(window, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetListener() {
@Override
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("test");
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
System.out.println("test");
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("test");
}
@Override
public void dragExit(DropTargetEvent dte) {
System.out.println("test");
}
@Override
public void drop(DropTargetDropEvent dtde) {
System.out.println("test");
}
}));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
