1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #001ee6}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #3e3c36; min-height: 12.0px}
23 span
.s1
{font: 18.0px Helvetica
}
24 span
.s2
{color: #000000}
25 span
.s3
{text-decoration: underline
}
26 span
.s4
{color: #696f8e}
27 span
.s5
{font: 14.0px Helvetica
}
28 span
.s6
{color: #0000bf}
29 span
.s7
{color: #007300}
30 span
.s8
{font: 11.0px Monaco
}
31 span
.s9
{color: #606060}
32 span
.Apple-tab-span
{white-space:pre
}
36 <p class=
"p1"><span class=
"s1"><b>SCDragView
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>an abstract superclass for drag views
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span></b></span></p>
37 <p class=
"p2"><br></p>
38 <p class=
"p3"><span class=
"s2"><b>Inherits from:
</b><a href=
"../../Core/Object.html"><b>Object
</b></a><b> :
</b><a href=
"SCView.html"><b>SCView
</b></a><b> :
</b><a href=
"SCStaticTextBase.html"><b>SCStaticTextBase
</b></a></span></p>
39 <p class=
"p2"><br></p>
40 <p class=
"p3"><span class=
"s2"><b>See also:
</b> <a href=
"SCDragSource.html"><span class=
"s3">SCDragSource
</span></a>,
<a href=
"SCDragSink.html"><span class=
"s3">SCDragSink
</span></a>,
<a href=
"SCDragBoth.html"><span class=
"s3">SCDragBoth
</span></a></span></p>
41 <p class=
"p2"><br></p>
42 <p class=
"p1">Users will not normally directly create instances of SCDragView, but only use it through its subclasses. The three subclasses, SCDragSource, SCDragSink, SCDragBoth, all function basically the same way: they are simple, graphically represented rectangles, which act as a drag-source, a drag target, or both. Their dragging behavior only differs from other GUI views, in that they do not require the cmd key to be held down for dragging. All other dragging functions are those defined by
<a href=
"SCView.html"><span class=
"s4">SCView
</span></a>. They inherit from
<a href=
"SCStaticTextBase.html"><span class=
"s4">SCStaticTextBase
</span></a>, and thus store their content in
<b>object
</b> and by default display their content using
<b>asString
</b>. You can keep their string independent of the content, if you set
<b>setBoth
</b>=false. You can also set a label to be displayed while dragging by using
<b>dragLabel_()
</b>.
</p>
43 <p class=
"p4"><br></p>
44 <p class=
"p5"><b>Subclassing and Internal Methods
</b></p>
45 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.
</p>
46 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
47 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>defaultGetDrag
</b></p>
48 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
49 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The method called by default when initiating a drag. Returns
<b>object
</b> .
</p>
50 <p class=
"p4"><br></p>
51 <p class=
"p5"><b>Examples
</b></p>
52 <p class=
"p8"><br></p>
54 <p class=
"p10"><span class=
"s2">s.waitForBoot({
<span class=
"Apple-tab-span"> </span></span>//only needed if you are using sound
</p>
55 <p class=
"p9"><span class=
"Apple-tab-span"> </span>w=
<span class=
"s6">Window
</span>.new.front;
</p>
56 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
57 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// store various kinds of objects in the drag source
</p>
58 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
59 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// a string source
</p>
60 <p class=
"p9"><span class=
"Apple-tab-span"> </span>a=
<span class=
"s6">DragSource
</span>(w,
<span class=
"s6">Rect
</span>(
10,
10,
150,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
61 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>a.object=
</span>"I am a string source"<span class=
"s2">;
</span></p>
62 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
63 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// a Float source
</p>
64 <p class=
"p9"><span class=
"Apple-tab-span"> </span>b=
<span class=
"s6">DragSource
</span>(w,
<span class=
"s6">Rect
</span>(
10,
40,
150,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
65 <p class=
"p9"><span class=
"Apple-tab-span"> </span>b.object=
2.234;
</p>
66 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
67 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// a Point source
</p>
68 <p class=
"p9"><span class=
"Apple-tab-span"> </span>c=
<span class=
"s6">DragSource
</span>(w,
<span class=
"s6">Rect
</span>(
10,
70,
150,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
69 <p class=
"p9"><span class=
"Apple-tab-span"> </span>c.object=
<span class=
"s6">Point
</span>(
20,
30);
</p>
70 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
71 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// A sound function source
</p>
72 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// dragLabel_() is used for the label while dragging
</p>
73 <p class=
"p9"><span class=
"Apple-tab-span"> </span>d=
<span class=
"s6">DragSource
</span>(w,
<span class=
"s6">Rect
</span>(
10,
100,
150,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
74 <p class=
"p9"><span class=
"Apple-tab-span"> </span>d.object={
<span class=
"s6">Synth
</span>(
<span class=
"s7">\default
</span>)};
</p>
75 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>d.dragLabel=
</span>" I am a sound function.\n My dragLabel_() is set \n to inform you about that "<span class=
"s2">;
</span></p>
76 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
77 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// A sound function source
</p>
78 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>//here the string label is independent of the content type (Function)
</p>
79 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// dragLabel_() is used for the label while dragging
</p>
80 <p class=
"p9"><span class=
"Apple-tab-span"> </span>f=
<span class=
"s6">DragSource
</span>(w,
<span class=
"s6">Rect
</span>(
10,
130,
150,
20)).align_(
<span class=
"s7">\center
</span>).setBoth_(
<span class=
"s6">false
</span>);
</p>
81 <p class=
"p9"><span class=
"Apple-tab-span"> </span>f.object={{
<span class=
"s6">SinOsc
</span>.ar(
440,
0,
0.4)}.play};
</p>
82 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>f.string=
</span>"My label is independent"<span class=
"s2">;
</span></p>
83 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>f.dragLabel=
</span>" My dragLabel_() says \n I am dragging a sound function "<span class=
"s2">;
</span></p>
84 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
85 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive anthing
</p>
86 <p class=
"p9"><span class=
"Apple-tab-span"> </span>g=
<span class=
"s6">DragSink
</span>(w,
<span class=
"s6">Rect
</span>(
170,
10,
200,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
87 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>g.string=
</span>"recieve anything, do nothing"<span class=
"s2">;
</span></p>
88 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
89 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive only floats
</p>
90 <p class=
"p9"><span class=
"Apple-tab-span"> </span>g=
<span class=
"s6">DragSink
</span>(w,
<span class=
"s6">Rect
</span>(
170,
40,
200,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
91 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>g.string=
</span>"I only like floats"<span class=
"s2">;
</span></p>
92 <p class=
"p9"><span class=
"Apple-tab-span"> </span>g
<span class=
"s8">.
</span>canReceiveDragHandler = {
<span class=
"s6">View
</span>.currentDrag.isFloat };
</p>
93 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
94 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive only numbers and points, and convert them to rects
</p>
95 <p class=
"p9"><span class=
"Apple-tab-span"> </span>h=
<span class=
"s6">DragSink
</span>(w,
<span class=
"s6">Rect
</span>(
170,
70,
200,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
96 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>h.string=
</span>"I convert to Rect"<span class=
"s2">;
</span></p>
97 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"s8">h.
</span>canReceiveDragHandler = {
<span class=
"s6">View
</span>.currentDrag.isKindOf(
<span class=
"s6">Number
</span>)||
<span class=
"s6">View
</span>.currentDrag.isKindOf(
<span class=
"s6">Point
</span>)};
</p>
98 <p class=
"p9"><span class=
"Apple-tab-span"> </span>h.receiveDragHandler={
<span class=
"s6">arg
</span> v; h.object=
<span class=
"s6">View
</span>.currentDrag.asRect};
</p>
99 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
100 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive only functions, and try to play them
</p>
101 <p class=
"p9"><span class=
"Apple-tab-span"> </span>i=
<span class=
"s6">DragSink
</span>(w,
<span class=
"s6">Rect
</span>(
170,
100,
200,
20)).align_(
<span class=
"s7">\center
</span>);
</p>
102 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span>i.string=
</span>"I evaluate a (sound) function"<span class=
"s2">;
</span></p>
103 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"s8">i.
</span>canReceiveDragHandler = {
<span class=
"s6">View
</span>.currentDrag.isKindOf(
<span class=
"s6">Function
</span>)};
</p>
104 <p class=
"p9"><span class=
"Apple-tab-span"> </span>i.receiveDragHandler={
<span class=
"s6">arg
</span> v;
</p>
105 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.object=
<span class=
"s6">View
</span>.currentDrag.value;
</p>
106 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.string=
</span>"click here for silence"<span class=
"s2">;
</span></p>
107 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.background_(
<span class=
"s6">Color
</span>.red)};
</p>
108 <p class=
"p9"><span class=
"Apple-tab-span"> </span>i.mouseDownAction_({i.object.free;i.string=
<span class=
"s9">"I evaluate a (sound) function"</span>;i.background_(
<span class=
"s6">Color
</span>.clear)});
</p>
109 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
110 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"s6">StaticText
</span>(w,
<span class=
"s6">Rect
</span>(
10,
200,
380,
50))
</p>
111 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.stringColor_(
<span class=
"s6">Color
</span>.white)
</p>
112 <p class=
"p12"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.string_(
</span>"Try dragging any item on the left -----> to any item on the right"<span class=
"s2">);
</span></p>
113 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
114 <p class=
"p9">});
</p>
116 <p class=
"p11"><br></p>
117 <p class=
"p11"><br></p>
118 <p class=
"p13"><br></p>
119 <p class=
"p13"><br></p>