public class SDrop extends Object
ƒ/** * basic example of a drop event and its contained informations. * drag an image, a file, a folder, a link into the sketch and see * what information the console spits out. */ import drop.*; SDrop drop; void setup() { size(400, 400); frameRate(30); drop = new SDrop(this); } void draw() { background(0); } void dropEvent(DropEvent theDropEvent) { // returns a string e.g. if you drag text from a texteditor // into the sketch this can be handy. println("toString()\t"+theDropEvent.toString()); // returns true if the dropped object is an image from // the harddisk or the browser. println("isImage()\t"+theDropEvent.isImage()); // returns true if the dropped object is a file or folder. println("isFile()\t"+theDropEvent.isFile()); // if the dropped object is a file or a folder you // can access it with file() . for more information see // http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html println("file()\t"+theDropEvent.file()); // returns true if the dropped object is a bookmark, a link, or a url. println("isURL()\t"+theDropEvent.isURL()); // returns the url as string. println("url()\t"+theDropEvent.url()); // returns the DropTargetDropEvent, for further information see // http://java.sun.com/j2se/1.4.2/docs/api/java/awt/dnd/DropTargetDropEvent.html println("dropTargetDropEvent()\t"+theDropEvent.dropTargetDropEvent()); }
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static String |
VERSION |
Constructor and Description |
---|
SDrop(processing.core.PApplet applet)
New Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addComponent(Component theComponent)
if you combine sojamo.drop with e.g.
|
void |
addDropListener(DropListener theListener)
add a drop listener to your sketch.
|
void |
removeDropListener(DropListener theListener)
remove a drop listener from your sketch.
|
public static boolean DEBUG
public static final String VERSION
public SDrop(processing.core.PApplet applet)
applet
- public void addComponent(Component theComponent)
theComponent
- Componentpublic void addDropListener(DropListener theListener)
theListener
- DropListener/** * DropListener demonstrates how to use a DropListener with * a custom class. */ import drop.*; SDrop drop; MyDropListener m; void setup() { size(400,400); drop = new SDrop(this); m = new MyDropListener(); drop.addDropListener(m); } void draw() { background(0); } void dropEvent(DropEvent theDropEvent) {} // a custom DropListener class. class MyDropListener extends drop.DropListener { MyDropListener() {} void dropEvent(DropEvent theEvent) { println("a drop event received from MyDropListener"); } }
public void removeDropListener(DropListener theListener)
theListener
- DropListener/** * DropListener demonstrates how to use a DropListener with * a custom class. */ import drop.*; SDrop drop; MyDropListener m; void setup() { size(400,400); drop = new SDrop(this); m = new MyDropListener(); drop.addDropListener(m); } void draw() { background(0); } void dropEvent(DropEvent theDropEvent) {} // a custom DropListener class. class MyDropListener extends drop.DropListener { MyDropListener() {} void dropEvent(DropEvent theEvent) { println("a drop event received from MyDropListener"); } }
Processing Library Drop by [Ramin Soleymani](http://diskordier.net), original sDrop by [Andreas Schlegel](http://www.sojamo.com). (c) 2015