public abstract class DropListener extends Object
/** * DropDropOnTarget demonstrates how to use a DropListener with * a dedicated target area when dragging and dropping an object * into your sketch. */ 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); m.draw(); } void dropEvent(DropEvent theDropEvent) {} // a custom DropListener class. class MyDropListener extends DropListener { int myColor; MyDropListener() { myColor = color(255); // set a target rect for drop event. setTargetRect(10,10,100,100); } void draw() { fill(myColor); rect(10,10,100,100); } // if a dragged object enters the target area. // dropEnter is called. void dropEnter() { myColor = color(255,0,0); } // if a dragged object leaves the target area. // dropLeave is called. void dropLeave() { myColor = color(255); } void dropEvent(DropEvent theEvent) { println("Dropped on MyDropListener"); } }
Constructor and Description |
---|
DropListener() |
Modifier and Type | Method and Description |
---|---|
void |
dropEnter() |
abstract void |
dropEvent(DropEvent theDropEvent) |
void |
dropLeave() |
void |
setTargetRect(float theX,
float theY,
float theWidth,
float theHeight)
set the target rect where things can be dropped into.
|
public final void setTargetRect(float theX, float theY, float theWidth, float theHeight)
theX
- floattheY
- floattheWidth
- floattheHeight
- floatpublic void dropEnter()
public void dropLeave()
public abstract void dropEvent(DropEvent theDropEvent)
Processing Library Drop by [Ramin Soleymani](http://diskordier.net), original sDrop by [Andreas Schlegel](http://www.sojamo.com). (c) 2015