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 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
24 span
.s1
{font: 18.0px Helvetica
}
25 span
.s2
{color: #000000}
26 span
.s3
{color: #5a65a5}
27 span
.s4
{color: #485abb}
28 span
.s5
{color: #6f717e}
29 span
.s6
{font: 14.0px Helvetica
}
30 span
.s7
{font: 9.0px Monaco
}
31 span
.s8
{color: #0000bf}
32 span
.s9
{color: #007300}
33 span
.s10
{font: 11.0px Monaco
}
34 span
.s11
{color: #606060}
35 span
.Apple-tab-span
{white-space:pre
}
39 <p class=
"p1"><span class=
"s1"><b>SCDragSink
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>a gui object for receiving drag and drop
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span></p>
40 <p class=
"p2"><br></p>
41 <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><b> :
</b><a href=
"SCDragView.html"><b>SCDragView
</b></a></span></p>
42 <p class=
"p4"><br></p>
43 <p class=
"p1">See
<a href=
"SCDragView.html"><span class=
"s3">SCDragView
</span></a> for description and examples, and
<a href=
"SCView.html"><span class=
"s4">SCView
</span></a> for a general description of the drag and drop mechanism.
</p>
44 <p class=
"p2"><br></p>
45 <p class=
"p5"><b>Creation / Class Methods
</b></p>
46 <p class=
"p6"><br></p>
47 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>*new (parent, bounds)
</b></p>
48 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
49 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>parent
</b>- the parent view.
</p>
50 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>bounds
</b>- an instance of
<a href=
"../../Geometry/Rect.html"><span class=
"s5">Rect
</span></a>, or a
<a href=
"../../Geometry/Point.html"><span class=
"s5">Point
</span></a> indicating width@height.
</p>
51 <p class=
"p2"><br></p>
52 <p class=
"p10"><b>Subclassing and Internal Methods
</b></p>
53 <p class=
"p7"><span class=
"s6"><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>
54 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
55 <p class=
"p7"><span class=
"Apple-tab-span"> </span><b>defaultCanReceiveDrag
</b></p>
56 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
57 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The method called by default when attempting to drop a drag in this object. By default, SCDragSink will respond to any drag.
</p>
58 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span></p>
59 <p class=
"p7"><span class=
"Apple-tab-span"> </span><b>defaultReceiveDrag
</b></p>
60 <p class=
"p8"><br></p>
61 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The default method called when a drag has been recieved.
</p>
62 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>By default, this sets the
<b>object
</b> to the
<b>currentDrag
</b> and performs the
<b>action.
</b></p>
63 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
64 <p class=
"p10"><b>Examples
</b></p>
65 <p class=
"p11"><br></p>
67 <p class=
"p13"><span class=
"s2">s.waitForBoot({
<span class=
"Apple-tab-span"> </span></span>//only needed if you are using sound
</p>
68 <p class=
"p12"><span class=
"Apple-tab-span"> </span>w=
<span class=
"s8">Window
</span>.new.front;
</p>
69 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
70 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// store various kinds of objects in the drag source
</p>
71 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
72 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// a string source
</p>
73 <p class=
"p12"><span class=
"Apple-tab-span"> </span>a=
<span class=
"s8">DragSource
</span>(w,
<span class=
"s8">Rect
</span>(
10,
10,
150,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
74 <p class=
"p14"><span class=
"s2"><span class=
"Apple-tab-span"> </span>a.object=
</span>"I am a string source"<span class=
"s2">;
</span></p>
75 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
76 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// a Float source
</p>
77 <p class=
"p12"><span class=
"Apple-tab-span"> </span>b=
<span class=
"s8">DragSource
</span>(w,
<span class=
"s8">Rect
</span>(
10,
40,
150,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
78 <p class=
"p12"><span class=
"Apple-tab-span"> </span>b.object=
2.234;
</p>
79 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
80 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// a Point source
</p>
81 <p class=
"p12"><span class=
"Apple-tab-span"> </span>c=
<span class=
"s8">DragSource
</span>(w,
<span class=
"s8">Rect
</span>(
10,
70,
150,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
82 <p class=
"p12"><span class=
"Apple-tab-span"> </span>c.object=
<span class=
"s8">Point
</span>(
20,
30);
</p>
83 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
84 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// A sound function source
</p>
85 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// dragLabel_() is used for the label while dragging
</p>
86 <p class=
"p12"><span class=
"Apple-tab-span"> </span>d=
<span class=
"s8">DragSource
</span>(w,
<span class=
"s8">Rect
</span>(
10,
100,
150,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
87 <p class=
"p12"><span class=
"Apple-tab-span"> </span>d.object={
<span class=
"s8">Synth
</span>(
<span class=
"s9">\default
</span>)};
</p>
88 <p class=
"p14"><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>
89 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
90 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// A sound function source
</p>
91 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>//here the string label is independent of the content type (Function)
</p>
92 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// dragLabel_() is used for the label while dragging
</p>
93 <p class=
"p12"><span class=
"Apple-tab-span"> </span>f=
<span class=
"s8">DragSource
</span>(w,
<span class=
"s8">Rect
</span>(
10,
130,
150,
20)).align_(
<span class=
"s9">\center
</span>).setBoth_(
<span class=
"s8">false
</span>);
</p>
94 <p class=
"p12"><span class=
"Apple-tab-span"> </span>f.object={{
<span class=
"s8">SinOsc
</span>.ar(
440,
0,
0.4)}.play};
</p>
95 <p class=
"p14"><span class=
"s2"><span class=
"Apple-tab-span"> </span>f.string=
</span>"My label is independent"<span class=
"s2">;
</span></p>
96 <p class=
"p14"><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>
97 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
98 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive anthing
</p>
99 <p class=
"p12"><span class=
"Apple-tab-span"> </span>g=
<span class=
"s8">DragSink
</span>(w,
<span class=
"s8">Rect
</span>(
170,
10,
200,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
100 <p class=
"p14"><span class=
"s2"><span class=
"Apple-tab-span"> </span>g.string=
</span>"recieve anything, do nothing"<span class=
"s2">;
</span></p>
101 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
102 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive only floats
</p>
103 <p class=
"p12"><span class=
"Apple-tab-span"> </span>g=
<span class=
"s8">DragSink
</span>(w,
<span class=
"s8">Rect
</span>(
170,
40,
200,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
104 <p class=
"p14"><span class=
"s2"><span class=
"Apple-tab-span"> </span>g.string=
</span>"I only like floats"<span class=
"s2">;
</span></p>
105 <p class=
"p12"><span class=
"Apple-tab-span"> </span>g
<span class=
"s10">.
</span>canReceiveDragHandler = {
<span class=
"s8">View
</span>.currentDrag.isFloat };
</p>
106 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
107 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive only numbers and points, and convert them to rects
</p>
108 <p class=
"p12"><span class=
"Apple-tab-span"> </span>h=
<span class=
"s8">DragSink
</span>(w,
<span class=
"s8">Rect
</span>(
170,
70,
200,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
109 <p class=
"p14"><span class=
"s2"><span class=
"Apple-tab-span"> </span>h.string=
</span>"I convert to Rect"<span class=
"s2">;
</span></p>
110 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"s10">h.
</span>canReceiveDragHandler = {
<span class=
"s8">View
</span>.currentDrag.isKindOf(
<span class=
"s8">Number
</span>)||
<span class=
"s8">View
</span>.currentDrag.isKindOf(
<span class=
"s8">Point
</span>)};
</p>
111 <p class=
"p12"><span class=
"Apple-tab-span"> </span>h.receiveDragHandler={
<span class=
"s8">arg
</span> v; h.object=
<span class=
"s8">View
</span>.currentDrag.asRect};
</p>
112 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
113 <p class=
"p13"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// receive only functions, and try to play them
</p>
114 <p class=
"p12"><span class=
"Apple-tab-span"> </span>i=
<span class=
"s8">DragSink
</span>(w,
<span class=
"s8">Rect
</span>(
170,
100,
200,
20)).align_(
<span class=
"s9">\center
</span>);
</p>
115 <p class=
"p14"><span class=
"s2"><span class=
"Apple-tab-span"> </span>i.string=
</span>"I evaluate a (sound) function"<span class=
"s2">;
</span></p>
116 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"s10">i.
</span>canReceiveDragHandler = {
<span class=
"s8">View
</span>.currentDrag.isKindOf(
<span class=
"s8">Function
</span>)};
</p>
117 <p class=
"p12"><span class=
"Apple-tab-span"> </span>i.receiveDragHandler={
<span class=
"s8">arg
</span> v;
</p>
118 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.object=
<span class=
"s8">View
</span>.currentDrag.value;
</p>
119 <p class=
"p14"><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>
120 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.background_(
<span class=
"s8">Color
</span>.red)};
</p>
121 <p class=
"p12"><span class=
"Apple-tab-span"> </span>i.mouseDownAction_({i.object.free;i.string=
<span class=
"s11">"I evaluate a (sound) function"</span>;i.background_(
<span class=
"s8">Color
</span>.clear)});
</p>
122 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
123 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"s8">StaticText
</span>(w,
<span class=
"s8">Rect
</span>(
10,
200,
380,
50))
</p>
124 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.stringColor_(
<span class=
"s8">Color
</span>.white)
</p>
125 <p class=
"p14"><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>
126 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
127 <p class=
"p12">});
</p>
129 <p class=
"p4"><br></p>
130 <p class=
"p4"><br></p>