Forgot a help fix: Drag a dock's title bar, not divider, to reposition
[supercollider.git] / HelpSource / Classes / DragBoth.schelp
blob3223e129aaf525b5b46207b7dff659881eea08e1
1 class:: DragBoth
2 redirect:: implClass
3 summary:: A simple drag-and-drop source and receiver
4 categories:: GUI>Views
5 related:: Classes/DragSink, Classes/DragSource
7 DESCRIPTION::
9 link::Classes/DragSource::, link::Classes/DragSink:: and link::Classes/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 emphasis::do not require the Cmd/Ctrl key to be held down to initiate dragging::.
11 Akin to link::Classes/StaticText:: they can store arbitrary content in the link::Classes/StaticText#-object#-object:: variable, and display it using link::Classes/Object#-asString::. You can set the displayed text separately using link::Classes/StaticText#-string#-string::, and keep it independent of the content if you set link::Classes/StaticText#-setBoth#-setBoth:: to code::false::.
13 strong::DragBoth::, specifically, strong::accepts any:: dropped data and stores it into the strong::-object:: variable, as well as gives that variable as data strong::for dragging::.
15 See: link::Classes/View#drag_and_drop:: for a general description of the drag and drop mechanism.
19 CLASSMETHODS::
21 PRIVATE:: key
25 INSTANCEMETHODS::
27 METHOD:: defaultGetDrag
28         RETURNS:: The link::Classes/StaticText#-object#-object::.
30 METHOD:: defaultCanReceiveDrag
31         RETURNS:: Allways True.
33 METHOD:: defaultReceiveDrag
34         Sets the link::Classes/StaticText#-object#-object:: to the current drag data.
38 EXAMPLES::
39 code::
41 w = Window.new.front;
42 w.addFlowLayout;
43 // store various kinds of objects in the drag source
45 // a string source
46 a = DragBoth(w, Rect(10, 10, 150, 20)).align_(\center).background_(Color.rand);
47 a.object = "drag us around";
49 a = DragBoth(w, Rect(10, 10, 150, 20)).align_(\center).background_(Color.rand);
50 a.object="SUPERCOLLIDER";
52 8.do{
53 a = DragBoth(w, Rect(10, 10, 150, 20)).align_(\center).background_(Color.rand);
54 a.receiveDragHandler = { arg obj; obj.object = View.currentDrag.scramble };