SuperCollider CLASSES

DragBoth

A simple drag-and-drop source and receiver
Subclasses: QDragBoth

Description

DragSource, DragSink and DragBoth are a set of view classes intended as simple-to-use drag-and-drop sources and destinations. They are graphically represented as a simple rectangle, and their specialty is that they do not require the Cmd/Ctrl key to be held down to initiate dragging.

Akin to StaticText they can store arbitrary content in the -object variable, and display it using Object: -asString. You can set the displayed text separately using -string, and keep it independent of the content if you set -setBoth to false.

DragBoth, specifically, accepts any dropped data and stores it into the -object variable, as well as gives that variable as data for dragging.

See: View: Drag%20and%20drop for a general description of the drag and drop mechanism.

Class Methods

Inherited class methods

Instance Methods

-defaultGetDrag

Returns:

The -object.

-defaultCanReceiveDrag

From superclass: DragSink

Returns:

Always True.

-defaultReceiveDrag

From superclass: DragSink

Sets the -object to the current drag data.

Inherited instance methods

Examples

(
w = Window.new.front;
w.addFlowLayout;
// store various kinds of objects in the drag source

// a string source
a = DragBoth(w, Rect(10, 10, 150, 20)).align_(\center).background_(Color.rand);
a.object = "drag us around";

a = DragBoth(w, Rect(10, 10, 150, 20)).align_(\center).background_(Color.rand);
a.object="SUPERCOLLIDER";

8.do{
a = DragBoth(w, Rect(10, 10, 150, 20)).align_(\center).background_(Color.rand);
a.receiveDragHandler = { arg obj; obj.object = View.currentDrag.scramble };
}
)