author | Claus Gittinger <cg@exept.de> |
Thu, 11 Nov 2004 10:14:01 +0100 | |
changeset 2022 | 6508caa8bdba |
parent 2013 | 5af91e0ed687 |
child 2025 | b40f8ad0d6fb |
permissions | -rw-r--r-- |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
2 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
1166 | 3 |
All Rights Reserved |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
4 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
5 |
This software is furnished under a license and may be used |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
10 |
hereby transferred. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
11 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
12 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
13 |
|
1397 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
341 | 16 |
Object subclass:#DragAndDropManager |
874 | 17 |
instanceVariableNames:'dropContext dragView dropAction dragOffset handler restoreBlock |
1661
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
18 |
alienCursor enabledCursor disabledCursor canDrop escapePressed |
1834 | 19 |
passiveAction autoScrollTask' |
1511 | 20 |
classVariableNames:'DragContextQuerySignal DragOriginatorQuerySignal |
21 |
DragOffsetQuerySignal ActiveDragAndDropManagers' |
|
628 | 22 |
poolDictionaries:'' |
874 | 23 |
category:'Interface-DragAndDrop' |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
24 |
! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
25 |
|
341 | 26 |
!DragAndDropManager class methodsFor:'documentation'! |
27 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
28 |
copyright |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
29 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
30 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
1166 | 31 |
All Rights Reserved |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
32 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
33 |
This software is furnished under a license and may be used |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
34 |
only in accordance with the terms of that license and with the |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
35 |
inclusion of the above copyright notice. This software may not |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
36 |
be provided or otherwise made available to, or used by, any |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
37 |
other person. No title to or ownership of the software is |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
38 |
hereby transferred. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
39 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
40 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
41 |
! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
42 |
|
348 | 43 |
documentation |
44 |
" |
|
45 |
this class provides low-level drag & drop mechanisms. |
|
46 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
47 |
Easy to use interface interfaces: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
48 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
49 |
A drag is usually initiated by a view or its application model, |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
50 |
when a selection is moved (for example, SelectionInListView can |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
51 |
be initializd to do so). |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
52 |
There, the view creates a collection of dropObjects from its selection, |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
53 |
and starts the drag operation with: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
54 |
|
1166 | 55 |
DragAndDropManager startDrag:collectionOfDragObjects from:aView. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
56 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
57 |
This easy to use interface starts a drag and also drops the collection |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
58 |
into the target view. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
59 |
While dragging, a thumbsUp cursor is shown, if the view-under-the-drag |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
60 |
can handle a drop, a thumbsDown is shown if not, and a question mark |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
61 |
is shown for alien views (which means: we dont know). |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
62 |
Alien view drop is supported (but no 'canDrop' query). |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
63 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
64 |
For rubber-band line dragging, two more easy-to-use startup methods are |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
65 |
provided: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
66 |
|
1166 | 67 |
DragAndDropManager |
68 |
startLineDragIn:aView at:position |
|
69 |
atEnd:aFourArgEndBlock |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
70 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
71 |
and: |
1166 | 72 |
DragAndDropManager |
73 |
startArrowDragIn:aView at:position |
|
74 |
atEnd:aFourArgEndBlock |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
75 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
76 |
both of the above expect a 4-arg block to be passed, which will be |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
77 |
evaluated at end-drag, with the target view, its viewID, the drop position |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
78 |
on the screen and within the target view as arguments. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
79 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
80 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
81 |
Expert interface: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
82 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
83 |
More control over the dragging (i.e. the drawing procedure) |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
84 |
can be optained, by passing a dragBlock and an endDrag action: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
85 |
|
1166 | 86 |
aDragAndDropMgr := DragAndDropManager new. |
87 |
aDragAndDropMgr dropObjects:(self collectionOfDragObjects). |
|
88 |
aDragAndDropMgr |
|
89 |
startOpaqueDrag:[:aPoint :aView :dropObjects | |
|
90 |
self |
|
91 |
showDragging:dropObjects |
|
92 |
in:aView |
|
93 |
at:aPoint - (xOffset@0) |
|
94 |
] |
|
95 |
offset:clickOffset |
|
96 |
extent:saveUnderExtent |
|
97 |
in:self |
|
98 |
at:clickPoint |
|
99 |
atEnd:[:v :vId :posScreen :posView | ... ] |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
100 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
101 |
the arguments are: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
102 |
startOpaqueDrag: |
1166 | 103 |
a 3-arg block, which is evaluated by the d&d manager whenever the |
104 |
mouse moves; it is supposed to draw the dropObjects at some position |
|
105 |
in the passed view. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
106 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
107 |
offset: |
1166 | 108 |
a clickOffset; drawing is offset by this amount |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
109 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
110 |
extent: |
1166 | 111 |
a save extent; the size of the screen area that must be saved during |
112 |
the drag operation |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
113 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
114 |
in: |
1166 | 115 |
initiating view |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
116 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
117 |
at: |
1166 | 118 |
position where d&d operation starts |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
119 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
120 |
atEnd: |
1166 | 121 |
a 4-arg block that is evaluated when the d&d is finished. |
122 |
It gets the target view (or nil, for alien views), the targets |
|
123 |
view ID (needed if its an alien view), the screen position and the |
|
124 |
relative position within the target view of the drop as arguments. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
125 |
|
1166 | 126 |
For internal (ST/X) views, the dropBlock should perform |
127 |
a simple canDrop:/doDrop message. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
128 |
|
1166 | 129 |
For alien views, the Displays d&d functions can be used. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
130 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
131 |
|
348 | 132 |
[author:] |
1166 | 133 |
Claus Gittinger |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
134 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
135 |
[see also:] |
1166 | 136 |
DemoView1, DemoView2, ... |
137 |
SelectionInListView FileBrowser - for a concrete example |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
138 |
|
348 | 139 |
" |
140 |
||
141 |
! |
|
142 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
143 |
examples |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
144 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
145 |
a button, which initiates dragging of a file-object |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
146 |
Notice that this can be dropped into the launchers panel, |
549 | 147 |
to open a fileBrowser on that directory ... |
1166 | 148 |
[exBegin] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
149 |
|o top v| |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
150 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
151 |
top := StandardSystemView new. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
152 |
v := Button label:'press for drag' in:top. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
153 |
v pressAction:[ |
1166 | 154 |
|o| |
155 |
o := DropObject newFile:('/etc'). |
|
156 |
DragAndDropManager startDrag:o from:v. |
|
157 |
v turnOff |
|
158 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
159 |
top openWithExtent:200@200 |
1166 | 160 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
161 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
162 |
initiate a drag with some offset: |
1166 | 163 |
[exBegin] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
164 |
|o top v| |
341 | 165 |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
166 |
top := StandardSystemView new. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
167 |
v := Button label:'press for drag' in:top. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
168 |
v pressAction:[ |
1166 | 169 |
|o| |
170 |
o := DropObject newFile:('.'). |
|
171 |
DragAndDropManager startDrag:o from:v offset:10@10. |
|
172 |
v turnOff |
|
173 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
174 |
top openWithExtent:200@200 |
1166 | 175 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
176 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
177 |
initiate a line drag: |
1166 | 178 |
[exBegin] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
179 |
|o top v endAction| |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
180 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
181 |
endAction := [ :v :vID :sPos :vPos | |
1166 | 182 |
Transcript show:'end drag in '. |
183 |
v isNil ifTrue:[ |
|
184 |
Transcript show:'alien view' |
|
185 |
] ifFalse:[ |
|
186 |
Transcript show:v |
|
187 |
]. |
|
188 |
Transcript show:' at screen: '; show:sPos; |
|
189 |
show:' in view: '; showCR:vPos |
|
190 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
191 |
top := StandardSystemView new. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
192 |
v := Button label:'press for drag' in:top. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
193 |
v pressAction:[ |
1166 | 194 |
DragAndDropManager |
195 |
startLineDragIn:v at:10@10 atEnd:endAction. |
|
196 |
v turnOff |
|
197 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
198 |
top openWithExtent:200@200 |
1166 | 199 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
200 |
|
874 | 201 |
more drag & drop; offset, displayObjects, ... |
1166 | 202 |
[exBegin] |
874 | 203 |
|dropObj topView pannel icon buttonAction addButton| |
204 |
||
205 |
topView := StandardSystemView new. |
|
206 |
pannel := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
|
207 |
pannel horizontalLayout:#fit. |
|
208 |
pannel verticalLayout:#fitSpace. |
|
209 |
||
210 |
icon := Image fromFile:('xpmBitmaps/QUESTION3.xpm'). |
|
211 |
dropObj := DropObject newFile:('.'). |
|
212 |
||
213 |
addButton := [:offset :label :dispObj| |button| |
|
1166 | 214 |
button := Button label:label in:pannel. |
874 | 215 |
|
1166 | 216 |
button pressAction:[ |
217 |
DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj. |
|
218 |
button turnOff. |
|
219 |
] |
|
874 | 220 |
]. |
221 |
||
881 | 222 |
addButton value:(0@-5) value:'String' value:'String'. |
874 | 223 |
addButton value:#topLeft value:'String' value:'String'. |
224 |
addButton value:#topRight value:'Text' value:(Text string:'hello' emphasis:#bold). |
|
225 |
addButton value:#bottomLeft value:'Icon' value:icon. |
|
226 |
addButton value:#bottomRight value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon'). |
|
227 |
addButton value:#center value:'Mixed' value:(Array with:'String' with:icon). |
|
228 |
||
229 |
topView label:'Drag & Drop'. |
|
230 |
topView openWithExtent:200@200. |
|
1166 | 231 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
232 |
" |
341 | 233 |
! ! |
234 |
||
628 | 235 |
!DragAndDropManager class methodsFor:'initialization'! |
236 |
||
237 |
initialize |
|
238 |
DragOriginatorQuerySignal := QuerySignal new. |
|
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
239 |
DragOffsetQuerySignal := QuerySignal new. |
1511 | 240 |
DragContextQuerySignal := QuerySignal new. |
1487 | 241 |
ActiveDragAndDropManagers := IdentityDictionary new. |
628 | 242 |
|
243 |
" |
|
244 |
self initialize |
|
245 |
" |
|
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
246 |
|
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
247 |
"Modified: 11.8.1997 / 00:54:21 / cg" |
1420 | 248 |
! ! |
249 |
||
250 |
!DragAndDropManager class methodsFor:'instance creation'! |
|
874 | 251 |
|
252 |
new |
|
253 |
^ self basicNew initialize |
|
628 | 254 |
! ! |
255 |
||
256 |
!DragAndDropManager class methodsFor:'Signal constants'! |
|
257 |
||
1511 | 258 |
dragContextQuerySignal |
259 |
^ DragContextQuerySignal |
|
260 |
! |
|
261 |
||
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
262 |
dragOffsetQuerySignal |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
263 |
^ DragOffsetQuerySignal |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
264 |
|
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
265 |
"Created: 11.8.1997 / 00:54:10 / cg" |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
266 |
! |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
267 |
|
628 | 268 |
dragOriginatorQuerySignal |
269 |
^ DragOriginatorQuerySignal |
|
270 |
! ! |
|
271 |
||
1842
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
272 |
!DragAndDropManager class methodsFor:'defaults'! |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
273 |
|
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
274 |
autoScrollDelayTimeMs |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
275 |
"time measured in milli-seconds the the autoscroll task is delayed |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
276 |
" |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
277 |
^ 200 |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
278 |
! ! |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
279 |
|
1487 | 280 |
!DragAndDropManager class methodsFor:'helpers'! |
281 |
||
282 |
saveDraw:aBlock device:aDevice |
|
283 |
|activeManager| |
|
284 |
||
285 |
activeManager := ActiveDragAndDropManagers at:aDevice ifAbsent:nil. |
|
286 |
activeManager isNil ifTrue:[ |
|
287 |
aBlock value |
|
288 |
] ifFalse:[ |
|
289 |
activeManager saveDraw:aBlock |
|
290 |
]. |
|
291 |
! ! |
|
292 |
||
293 |
!DragAndDropManager class methodsFor:'queries'! |
|
294 |
||
295 |
isDragAndDropActiveOnDevice:aDevice |
|
296 |
^ ActiveDragAndDropManagers includesKey:aDevice |
|
297 |
! ! |
|
298 |
||
1776 | 299 |
!DragAndDropManager class methodsFor:'simple start-drop source'! |
874 | 300 |
|
301 |
startDragFrom:aView dropSource:aDropSource |
|
302 |
"start a drop at the current pointer position. |
|
303 |
" |
|
304 |
^ (self new) startDragFrom:aView dropSource:aDropSource |
|
305 |
! ! |
|
306 |
||
1776 | 307 |
!DragAndDropManager class methodsFor:'simple start-generic'! |
874 | 308 |
|
309 |
startDrag:draggableObjects from:aView |
|
310 |
"start a drop at the current pointer position |
|
311 |
" |
|
312 |
^ self startDrag:draggableObjects |
|
1166 | 313 |
from:aView |
314 |
offset:0@0 |
|
315 |
atEnd:nil |
|
316 |
display:draggableObjects |
|
874 | 317 |
|
318 |
" |
|
319 |
EXAMPLE: |
|
320 |
||
321 |
|button| |
|
322 |
||
323 |
button := (Button label:'press me'). |
|
324 |
||
325 |
button pressAction:[ |
|
1166 | 326 |
DragAndDropManager startDrag:(DropObject newFile:('.')) from:button. |
327 |
button turnOff |
|
874 | 328 |
]. |
329 |
||
330 |
button openAt:100@100 |
|
331 |
" |
|
332 |
! |
|
333 |
||
334 |
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock |
|
335 |
"start a drop at the current pointer position |
|
336 |
When finished, the endAction is called with four args: |
|
337 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
338 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
339 |
" |
|
340 |
^ self startDrag:draggableObjects |
|
1166 | 341 |
from:aView |
342 |
offset:0@0 |
|
343 |
atEnd:aFourArgEndBlock |
|
344 |
display:draggableObjects |
|
874 | 345 |
|
346 |
" |
|
347 |
EXAMPLE: |
|
348 |
||
349 |
|button| |
|
350 |
||
351 |
button := (Button label:'press me'). |
|
352 |
||
353 |
button pressAction:[ |
|
1166 | 354 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
355 |
from:button |
|
356 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
357 |
Transcript showCR:'target view: ', targetView printString. |
|
358 |
Transcript showCR:'target id: ', targetViewId printString. |
|
359 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
360 |
Transcript showCR:'point target: ', targetPoint printString. |
|
361 |
]. |
|
362 |
button turnOff |
|
874 | 363 |
]. |
364 |
||
365 |
button openAt:100@100 |
|
366 |
" |
|
367 |
||
368 |
! |
|
369 |
||
370 |
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock display:something |
|
371 |
"start a drop at the current pointer position |
|
372 |
When finished, the endAction is called with four args: |
|
373 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
374 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
375 |
" |
|
376 |
^ self startDrag:draggableObjects |
|
1166 | 377 |
from:aView |
378 |
offset:0@0 |
|
379 |
atEnd:aFourArgEndBlock |
|
380 |
display:something |
|
874 | 381 |
|
382 |
" |
|
383 |
EXAMPLE: |
|
384 |
||
385 |
|button| |
|
386 |
||
387 |
button := (Button label:'press me'). |
|
388 |
||
389 |
button pressAction:[ |
|
1166 | 390 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
391 |
from:button |
|
392 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
393 |
Transcript showCR:'target view: ', targetView printString. |
|
394 |
Transcript showCR:'target id: ', targetViewId printString. |
|
395 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
396 |
Transcript showCR:'point target: ', targetPoint printString. |
|
397 |
] |
|
398 |
display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))). |
|
399 |
button turnOff |
|
874 | 400 |
]. |
401 |
||
402 |
button openAt:100@100 |
|
403 |
" |
|
404 |
! |
|
405 |
||
406 |
startDrag:draggableObjects from:aView display:something |
|
407 |
"start a drop at the current pointer position |
|
408 |
" |
|
409 |
^ self startDrag:draggableObjects |
|
1166 | 410 |
from:aView |
411 |
offset:0@0 |
|
412 |
atEnd:nil |
|
413 |
display:something |
|
874 | 414 |
|
415 |
" |
|
416 |
EXAMPLE: |
|
417 |
||
418 |
|dropObj topView pannel icon buttonAction addButton| |
|
419 |
||
420 |
topView := StandardSystemView new. |
|
421 |
pannel := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
|
422 |
pannel horizontalLayout:#fit. |
|
423 |
pannel verticalLayout:#fitSpace. |
|
424 |
||
425 |
icon := Image fromFile:('xpmBitmaps/QUESTION3.xpm'). |
|
426 |
dropObj := DropObject newFile:('.'). |
|
427 |
||
428 |
addButton := [:label :dispObj| |button| |
|
1166 | 429 |
button := Button label:label in:pannel. |
874 | 430 |
|
1166 | 431 |
button pressAction:[ |
432 |
DragAndDropManager startDrag:dropObj from:button display:dispObj. |
|
433 |
button turnOff. |
|
434 |
] |
|
874 | 435 |
]. |
436 |
||
437 |
addButton value:'String' value:'String'. |
|
438 |
addButton value:'Text' value:(Text string:'hello' emphasis:#bold). |
|
439 |
addButton value:'Icon' value:icon. |
|
440 |
addButton value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon'). |
|
441 |
addButton value:'Mixed' value:(Array with:'String' with:icon). |
|
442 |
||
443 |
topView label:'Drag & Drop'. |
|
444 |
topView openWithExtent:200@200. |
|
445 |
" |
|
446 |
! |
|
447 |
||
448 |
startDrag:draggableObjects from:aView offset:anOffset |
|
449 |
"start a drop at the current pointer position |
|
450 |
" |
|
451 |
^ self startDrag:draggableObjects |
|
1166 | 452 |
from:aView |
453 |
offset:anOffset |
|
454 |
atEnd:nil |
|
455 |
display:draggableObjects |
|
874 | 456 |
|
457 |
" |
|
458 |
EXAMPLE: |
|
459 |
||
460 |
|button| |
|
461 |
||
462 |
button := (Button label:'press me'). |
|
463 |
||
464 |
button pressAction:[ |
|
1166 | 465 |
DragAndDropManager startDrag:(DropObject newFile:('.')) from:button offset:(-10 @ -10). |
466 |
button turnOff |
|
874 | 467 |
]. |
468 |
||
469 |
button openAt:100@100 |
|
470 |
" |
|
471 |
||
472 |
! |
|
473 |
||
474 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock |
|
475 |
"start a drop at the current pointer position |
|
476 |
When finished, the endAction is called with four args: |
|
477 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
478 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
479 |
" |
|
480 |
^ self startDrag:draggableObjects |
|
1166 | 481 |
from:aView |
482 |
offset:anOffset |
|
483 |
atEnd:aFourArgEndBlock |
|
484 |
display:draggableObjects |
|
874 | 485 |
|
486 |
" |
|
487 |
EXAMPLE: |
|
488 |
||
489 |
|button| |
|
490 |
||
491 |
button := (Button label:'press me'). |
|
492 |
||
493 |
button pressAction:[ |
|
1166 | 494 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
495 |
from:button |
|
496 |
offset:(-10 @ -10) |
|
497 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
498 |
Transcript showCR:'target view: ', targetView printString. |
|
499 |
Transcript showCR:'target id: ', targetViewId printString. |
|
500 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
501 |
Transcript showCR:'point target: ', targetPoint printString. |
|
502 |
]. |
|
503 |
button turnOff |
|
874 | 504 |
]. |
505 |
||
506 |
button openAt:100@100 |
|
507 |
" |
|
508 |
||
509 |
! |
|
510 |
||
511 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock display:something |
|
512 |
"start a drop at the current pointer position |
|
513 |
When finished, the endAction is called with four args: |
|
514 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
515 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
516 |
" |
|
517 |
|manager| |
|
518 |
||
519 |
manager := self new. |
|
520 |
||
521 |
manager startDrag:draggableObjects |
|
1166 | 522 |
from:aView |
523 |
offset:anOffset |
|
524 |
atEnd:aFourArgEndBlock |
|
525 |
display:something. |
|
874 | 526 |
|
527 |
^ manager |
|
528 |
||
529 |
" |
|
530 |
EXAMPLE: |
|
531 |
||
532 |
|button| |
|
533 |
||
534 |
button := (Button label:'press me'). |
|
535 |
||
536 |
button pressAction:[ |
|
1166 | 537 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
538 |
from:button |
|
539 |
offset:(-10 @ -10) |
|
540 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
541 |
Transcript showCR:'target view: ', targetView printString. |
|
542 |
Transcript showCR:'target id: ', targetViewId printString. |
|
543 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
544 |
Transcript showCR:'point target: ', targetPoint printString. |
|
545 |
] |
|
546 |
display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))). |
|
547 |
button turnOff |
|
874 | 548 |
]. |
549 |
||
550 |
button openAt:100@100 |
|
551 |
" |
|
552 |
||
553 |
! |
|
554 |
||
555 |
startDrag:draggableObjects from:aView offset:anOffset display:something |
|
556 |
"start a drop at the current pointer position |
|
557 |
" |
|
558 |
^ self startDrag:draggableObjects |
|
1166 | 559 |
from:aView |
560 |
offset:anOffset |
|
561 |
atEnd:nil |
|
562 |
display:something |
|
874 | 563 |
|
564 |
" |
|
565 |
EXAMPLE: |
|
566 |
||
567 |
|dropObj topView pannel icon buttonAction addButton| |
|
568 |
||
569 |
topView := StandardSystemView new. |
|
570 |
pannel := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
|
571 |
pannel horizontalLayout:#fit. |
|
572 |
pannel verticalLayout:#fitSpace. |
|
573 |
||
574 |
icon := Image fromFile:('xpmBitmaps/QUESTION3.xpm'). |
|
575 |
dropObj := DropObject newFile:('.'). |
|
576 |
||
577 |
addButton := [:offset :label :dispObj| |button| |
|
1166 | 578 |
button := Button label:label in:pannel. |
874 | 579 |
|
1166 | 580 |
button pressAction:[ |
581 |
DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj. |
|
582 |
button turnOff. |
|
583 |
] |
|
874 | 584 |
]. |
585 |
||
586 |
addButton value:#topLeft value:'String' value:'String'. |
|
587 |
addButton value:#topRight value:'Text' value:(Text string:'hello' emphasis:#bold). |
|
588 |
addButton value:#bottomLeft value:'Icon' value:icon. |
|
589 |
addButton value:#bottomRight value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon'). |
|
590 |
addButton value:#center value:'Mixed' value:(Array with:'String' with:icon). |
|
591 |
||
592 |
topView label:'Drag & Drop'. |
|
593 |
topView openWithExtent:200@200. |
|
594 |
" |
|
595 |
||
596 |
! ! |
|
597 |
||
1776 | 598 |
!DragAndDropManager class methodsFor:'simple start-lines'! |
397 | 599 |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
600 |
startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
601 |
"start a rubber-arrow-line dragging in aView at dragPoint. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
602 |
When finished, evaluate the fourArgBlock with targetView, |
874 | 603 |
targetID, screenPosition and targetViewPosition as arguments |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
604 |
" |
874 | 605 |
^ self new startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
606 |
|
874 | 607 |
" |
608 |
EXAMPLE: |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
609 |
|
874 | 610 |
|button| |
397 | 611 |
|
874 | 612 |
button := (Button label:'press me'). |
861 | 613 |
|
874 | 614 |
button pressAction:[ |
1166 | 615 |
button turnOff. |
861 | 616 |
|
1166 | 617 |
DragAndDropManager startArrowDragIn:button |
618 |
at:(button preferredExtent // 2) |
|
619 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
620 |
targetView isNil ifTrue:[ |
|
621 |
Transcript show:'alien view' |
|
622 |
] ifFalse:[ |
|
623 |
Transcript showCR:'target: ', targetView printString |
|
624 |
]. |
|
625 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
626 |
Transcript showCR:'point target: ', targetPoint printString. |
|
627 |
] |
|
874 | 628 |
]. |
629 |
button openAt:100@100 |
|
630 |
" |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
631 |
! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
632 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
633 |
startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
634 |
"start a rubber-line dragging in aView at dragPoint. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
635 |
When finished, evaluate the fourArgBlock with targetView, |
874 | 636 |
targetID, screenPosition and targetViewPosition as arguments |
637 |
" |
|
638 |
^ self new startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock |
|
639 |
||
640 |
" |
|
641 |
EXAMPLE: |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
642 |
|
874 | 643 |
|button| |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
644 |
|
874 | 645 |
button := (Button label:'press me'). |
646 |
||
647 |
button pressAction:[ |
|
1166 | 648 |
button turnOff. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
649 |
|
1166 | 650 |
DragAndDropManager startLineDragIn:button |
651 |
at:(button preferredExtent // 2) |
|
652 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
653 |
targetView isNil ifTrue:[ |
|
654 |
Transcript show:'alien view' |
|
655 |
] ifFalse:[ |
|
656 |
Transcript showCR:'target: ', targetView printString |
|
657 |
]. |
|
658 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
659 |
Transcript showCR:'point target: ', targetPoint printString. |
|
660 |
] |
|
874 | 661 |
]. |
662 |
button openAt:100@100 |
|
663 |
" |
|
397 | 664 |
! ! |
665 |
||
1511 | 666 |
!DragAndDropManager class methodsFor:'translation'! |
667 |
||
668 |
translatePointFromScreen:aPoint toView:aView |
|
669 |
"translate a point to screen |
|
670 |
" |
|
671 |
|device trans point offset| |
|
672 |
||
673 |
device := aView device. |
|
674 |
||
675 |
"/ |
|
676 |
"/ translate to view |
|
677 |
"/ |
|
1517
5f4d38273014
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
678 |
offset := device translatePoint:0@0 fromView:(device rootView) toView:aView. |
1511 | 679 |
point := aPoint + offset. |
680 |
||
681 |
"/ |
|
682 |
"/ get device coordinates |
|
683 |
"/ |
|
684 |
(trans := aView transformation) notNil ifTrue:[ |
|
685 |
point := trans applyInverseTo:point |
|
686 |
]. |
|
687 |
^ point |
|
688 |
! |
|
689 |
||
690 |
translatePointToScreen:aPoint from:aView |
|
691 |
"translate a point to screen |
|
692 |
" |
|
693 |
|device trans point offset| |
|
694 |
||
1686 | 695 |
aView isRootView ifTrue:[^ aPoint]. |
1511 | 696 |
device := aView device. |
697 |
"/ |
|
698 |
"/ get device coordinates |
|
699 |
"/ |
|
700 |
(trans := aView transformation) notNil ifTrue:[ |
|
701 |
point := trans applyTo:aPoint |
|
702 |
] ifFalse:[ |
|
703 |
point := aPoint |
|
704 |
]. |
|
705 |
"/ |
|
706 |
"/ translate to screen |
|
707 |
"/ |
|
1517
5f4d38273014
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
708 |
offset := device translatePoint:0@0 fromView:aView toView:(device rootView). |
1686 | 709 |
^ offset + point |
1511 | 710 |
! ! |
711 |
||
394 | 712 |
!DragAndDropManager methodsFor:'accessing'! |
713 |
||
861 | 714 |
device |
715 |
"returns the device of the source view |
|
716 |
" |
|
717 |
^ dragView device |
|
718 |
||
719 |
||
720 |
! |
|
721 |
||
2013 | 722 |
dragHandler |
723 |
"returns the current active handler which is responsible for drawing ..." |
|
724 |
||
725 |
^ handler |
|
726 |
! |
|
727 |
||
728 |
dragHandler:aNewHandler |
|
729 |
"set the active handler which is responsible for drawing ..." |
|
730 |
||
731 |
handler := aNewHandler. |
|
732 |
! |
|
733 |
||
874 | 734 |
dropContext |
735 |
"return the current context |
|
736 |
" |
|
737 |
^ dropContext |
|
738 |
! |
|
739 |
||
397 | 740 |
dropObjects |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
741 |
"return the current dropObject collection" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
742 |
|
874 | 743 |
^ dropContext dropObjects |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
744 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
745 |
"Modified: 19.4.1997 / 10:19:06 / cg" |
397 | 746 |
! |
747 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
748 |
dropObjects:aCollectionOfDropObjects |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
749 |
"set the current dropObject collection" |
397 | 750 |
|
874 | 751 |
^ dropContext dropObjects:aCollectionOfDropObjects |
861 | 752 |
! |
753 |
||
754 |
font |
|
755 |
"returns the font of the source view |
|
756 |
" |
|
757 |
^ dragView font |
|
758 |
||
759 |
||
874 | 760 |
! |
761 |
||
1661
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
762 |
passiveAction:aBlockOrNil |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
763 |
self removePassiveAction. |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
764 |
aBlockOrNil notNil ifTrue:[ |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
765 |
passiveAction := Processor addTimedBlock:aBlockOrNil afterMilliseconds:100 |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
766 |
]. |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
767 |
! |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
768 |
|
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
769 |
removePassiveAction |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
770 |
passiveAction notNil ifTrue:[ |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
771 |
Processor removeTimeoutWithID:passiveAction. |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
772 |
passiveAction := nil. |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
773 |
]. |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
774 |
! |
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
775 |
|
874 | 776 |
sourceWidget |
777 |
^ dragView |
|
778 |
! ! |
|
779 |
||
1397 | 780 |
!DragAndDropManager methodsFor:'accessing-cursor'! |
874 | 781 |
|
782 |
alienCursor:aCursorOrImage |
|
783 |
"set the cursor used for an alien widget; not an ST/X view |
|
784 |
" |
|
785 |
aCursorOrImage isImage ifTrue:[ |
|
1166 | 786 |
alienCursor := Cursor fromImage:aCursorOrImage |
874 | 787 |
] ifFalse:[ |
1166 | 788 |
(aCursorOrImage isMemberOf:Cursor) ifTrue:[ |
789 |
alienCursor := aCursorOrImage |
|
790 |
] ifFalse:[ |
|
791 |
"/ |
|
792 |
"/ use disabled cursor |
|
793 |
"/ |
|
794 |
alienCursor := nil |
|
795 |
] |
|
874 | 796 |
] |
797 |
! |
|
798 |
||
799 |
disabledCursor:aCursorOrImage |
|
800 |
"set the cursor for an ST/X view, which can not drop the objects |
|
801 |
" |
|
802 |
aCursorOrImage isImage ifTrue:[ |
|
1166 | 803 |
disabledCursor := Cursor fromImage:aCursorOrImage |
874 | 804 |
] ifFalse:[ |
1166 | 805 |
(aCursorOrImage isMemberOf:Cursor) ifTrue:[ |
806 |
disabledCursor := aCursorOrImage |
|
807 |
] |
|
874 | 808 |
] |
809 |
! |
|
810 |
||
811 |
enabledCursor:aCursorOrImage |
|
812 |
"set the cursor for an ST/X view, which can drop the objects |
|
813 |
" |
|
814 |
aCursorOrImage isImage ifTrue:[ |
|
1166 | 815 |
enabledCursor := Cursor fromImage:aCursorOrImage |
874 | 816 |
] ifFalse:[ |
1166 | 817 |
(aCursorOrImage isMemberOf:Cursor) ifTrue:[ |
818 |
enabledCursor := aCursorOrImage |
|
819 |
] |
|
874 | 820 |
] |
821 |
||
822 |
! ! |
|
823 |
||
1678 | 824 |
!DragAndDropManager methodsFor:'dragging-drop source'! |
874 | 825 |
|
826 |
startDragFrom:aView dropSource:aDropSource |
|
1718 | 827 |
"start a drag at the current pointer position. |
874 | 828 |
" |
829 |
^ self startDragFrom:aView dropSource:aDropSource offset:#topLeft "/ #center |
|
830 |
! |
|
831 |
||
832 |
startDragFrom:aView dropSource:aDropSource offset:anOffset |
|
1718 | 833 |
"start a drag at the current pointer position. |
874 | 834 |
" |
835 |
dropContext dropSource:aDropSource. |
|
836 |
||
837 |
^ self startDrag:(aDropSource dropObjects) |
|
1718 | 838 |
from:aView |
839 |
offset:anOffset |
|
840 |
atEnd:nil |
|
841 |
display:(aDropSource displayObjects) |
|
874 | 842 |
! ! |
843 |
||
1678 | 844 |
!DragAndDropManager methodsFor:'dragging-easy startup'! |
874 | 845 |
|
846 |
startDrag:draggableObjects from:aView |
|
847 |
"start a drop at the current pointer position |
|
848 |
" |
|
849 |
^ self startDrag:draggableObjects |
|
1166 | 850 |
from:aView |
851 |
offset:0@0 |
|
874 | 852 |
! |
853 |
||
854 |
startDrag:draggableObjects from:aView display:something |
|
855 |
"start a drop at the current pointer position. |
|
856 |
" |
|
857 |
^ self startDrag:draggableObjects |
|
1166 | 858 |
from:aView |
859 |
offset:nil |
|
860 |
atEnd:nil |
|
861 |
display:something |
|
874 | 862 |
! |
863 |
||
864 |
startDrag:draggableObjects from:aView offset:anOffset |
|
865 |
"start a drop at the current pointer position with an offset |
|
866 |
" |
|
867 |
^ self startDrag:draggableObjects |
|
1166 | 868 |
from:aView |
869 |
offset:anOffset |
|
870 |
atEnd:nil |
|
874 | 871 |
! |
872 |
||
873 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock |
|
874 |
"start a drop at the current pointer position. |
|
875 |
When finished, the endAction is called with four args: |
|
876 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
877 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
878 |
" |
|
879 |
^ self startDrag:draggableObjects |
|
1166 | 880 |
from:aView |
881 |
offset:anOffset |
|
882 |
atEnd:aFourArgEndBlock |
|
883 |
display:draggableObjects |
|
874 | 884 |
! |
885 |
||
886 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgBlock display:something |
|
887 |
"start a drop at the current pointer position. |
|
888 |
When finished, the endAction is called with four args: |
|
889 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
890 |
the dropPoint in root-coordinates and the dropPoint within the targetView. |
|
891 |
" |
|
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
892 |
|height width fontWdt offset ascent device dispObjs list space| |
874 | 893 |
|
894 |
self dropObjects:draggableObjects. |
|
895 |
||
896 |
self dropObjects size == 0 ifTrue:[ |
|
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
897 |
^ self |
874 | 898 |
]. |
899 |
||
900 |
device := aView device. |
|
901 |
space := 1. |
|
902 |
height := space negated. |
|
903 |
width := 0. |
|
904 |
fontWdt := aView font width. |
|
905 |
ascent := aView font ascent. |
|
906 |
||
907 |
(list := something) isNil ifTrue:[ |
|
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
908 |
list := self dropObjects |
874 | 909 |
] ifFalse:[ |
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
910 |
(list isCollection not or:[list isString]) ifTrue:[ |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
911 |
list := Array with:something |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
912 |
] |
874 | 913 |
]. |
914 |
dispObjs := OrderedCollection new. |
|
915 |
||
916 |
list do:[:el| |
|
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
917 |
|obj asc| |
874 | 918 |
|
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
919 |
obj := self displayObjectFor:el on:device. |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
920 |
asc := (obj respondsTo:#string) ifTrue:[ascent] ifFalse:[0]. |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
921 |
height := height + space. |
874 | 922 |
|
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
923 |
dispObjs add:(Array with:obj with:(0 @ (height + asc))). |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
924 |
width := width max:(obj widthOn:aView). |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
925 |
height := height + (obj heightOn:aView). |
874 | 926 |
]. |
927 |
||
881 | 928 |
anOffset isSymbol ifTrue:[ |
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
929 |
offset := (0@0 extent:(width @ height)) perform:anOffset. |
881 | 930 |
] ifFalse:[ |
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
931 |
offset := anOffset ? (0@0). |
881 | 932 |
]. |
933 |
offset := offset rounded. |
|
874 | 934 |
|
935 |
dispObjs do:[:el| el at:2 put:((el at:2) - offset) ]. |
|
936 |
||
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
937 |
self startOpaqueDrag:[:p :v| |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
938 |
|cursor hX hY pDraw| |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
939 |
|
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
940 |
cursor := dragView cursor. |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
941 |
hX := cursor hotX. |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
942 |
hY := cursor hotY. |
1497
dff682eb74fc
avoid jumping icon while moving
Claus Gittinger <cg@exept.de>
parents:
1490
diff
changeset
|
943 |
pDraw := p "- (hX@hY) + cursor extent". |
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
944 |
dispObjs do:[:el| (el at:1) displayOn:v |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
945 |
at:pDraw + (el at:2) |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
946 |
] |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
947 |
] |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
948 |
offset:offset |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
949 |
extent:width @ height |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
950 |
in:aView |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
951 |
at:nil |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
952 |
atEnd:aFourArgBlock |
881 | 953 |
|
954 |
"Modified: / 31.3.1998 / 11:18:04 / cg" |
|
874 | 955 |
! |
956 |
||
957 |
startDrag:draggableObjects from:aView offset:anOffset display:something |
|
958 |
"start a drop at the current pointer position. |
|
959 |
" |
|
960 |
^ self startDrag:draggableObjects |
|
1166 | 961 |
from:aView |
962 |
offset:anOffset |
|
963 |
atEnd:nil |
|
964 |
display:something |
|
394 | 965 |
! ! |
966 |
||
1678 | 967 |
!DragAndDropManager methodsFor:'dragging-generic'! |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
968 |
|
348 | 969 |
startGenericDrag:aTwoArgDragBlock in:aView at:p atEnd:aFourArgEndBlock |
970 |
"start a generic (caller-provided drag); |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
971 |
Here, an inverting drag is initiated (i.e. the drawing is undone |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
972 |
by inverting again). See startOpaqueDrag for another variant. |
348 | 973 |
the dragBlock, aTwoArgDragBlock will be called with two args |
974 |
aPoint and a drawingGC, to perform the drawing at some dragPoint. |
|
975 |
The drag starts in aView at point p. |
|
976 |
When finished, the endAction is called with four args: |
|
977 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
874 | 978 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
979 |
" |
|
980 |
^ self startOpaqueDrag:aTwoArgDragBlock |
|
1166 | 981 |
offset:nil |
982 |
extent:nil |
|
983 |
in:aView |
|
984 |
at:nil |
|
985 |
atEnd:aFourArgEndBlock |
|
394 | 986 |
! |
987 |
||
874 | 988 |
startOpaqueDrag:aDragBlock offset:offs extent:anExtent in:aView at:aDummyPoint atEnd:aFourArgEndBlock |
989 |
"start an opaque or generic opaque (caller-provided drag); |
|
394 | 990 |
opaque drag means, that the drawing cannot be undone by two inverting |
991 |
draws, but instead, the area under the dragged object must be saved |
|
874 | 992 |
and restored. The areas size to be saved/restored is passed in anExtent. |
993 |
the dragBlock, aDragBlock will be called with up to three args aPoint, a |
|
994 |
drawingGC and the display objects, to perform the drawing at some dragPoint. |
|
394 | 995 |
The drag starts in aView at point p. |
996 |
When finished, the endAction is called with four args: |
|
997 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
874 | 998 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
999 |
" |
|
1000 |
|handler numArgs dragBlock dobjs| |
|
394 | 1001 |
|
874 | 1002 |
dragOffset := offs ? (Point x:0 y:0). |
1003 |
numArgs := aDragBlock numArgs. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1004 |
|
874 | 1005 |
numArgs == 3 ifTrue:[ |
1289 | 1006 |
dobjs := self dropObjects. |
1007 |
dragBlock := [:p :v| aDragBlock value:p value:v value:dobjs ] |
|
874 | 1008 |
] ifFalse:[ |
1289 | 1009 |
numArgs == 1 ifTrue:[ |
1010 |
dragBlock := [:p :v| aDragBlock value:p ] |
|
1011 |
] ifFalse:[ |
|
1012 |
dragBlock := aDragBlock |
|
1013 |
] |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1014 |
]. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1015 |
|
874 | 1016 |
anExtent isNil ifTrue:[ |
1289 | 1017 |
handler := DragHandler startGenericDrag:dragBlock. |
874 | 1018 |
] ifFalse:[ |
1289 | 1019 |
handler := DragHandler startOpaqueDrag:dragBlock extent:anExtent offset:dragOffset. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1020 |
]. |
1289 | 1021 |
self doStart:handler for:aView atEnd:aFourArgEndBlock. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1022 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1023 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1024 |
|
1678 | 1025 |
!DragAndDropManager methodsFor:'dragging-lines'! |
341 | 1026 |
|
874 | 1027 |
startArrowDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock |
1028 |
"start a line-drag of an arrow-line. |
|
1029 |
The drag starts in aView at point aStartPoint. |
|
1030 |
When finished, the endAction is called with four args: |
|
1031 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
1032 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
1033 |
" |
|
1034 |
|p| |
|
341 | 1035 |
|
1511 | 1036 |
p := self class translatePointToScreen:aStartPoint from:aView. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1037 |
|
874 | 1038 |
self doStart:(DragHandler startArrowDragAt:p) |
1511 | 1039 |
for:aView |
1040 |
atEnd:aFourArgEndBlock |
|
341 | 1041 |
! |
1042 |
||
874 | 1043 |
startLineDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock |
1044 |
"start a line-drag of a normal line. |
|
1045 |
The drag starts in aView at point aStartPoint. |
|
348 | 1046 |
When finished, the endAction is called with four args: |
1047 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
874 | 1048 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
1049 |
" |
|
1050 |
|p| |
|
341 | 1051 |
|
1511 | 1052 |
p := self class translatePointToScreen:aStartPoint from:aView. |
348 | 1053 |
|
874 | 1054 |
self doStart:(DragHandler startLineDragAt:p) |
1511 | 1055 |
for:aView |
1056 |
atEnd:aFourArgEndBlock |
|
341 | 1057 |
! ! |
1058 |
||
397 | 1059 |
!DragAndDropManager methodsFor:'drawing'! |
1060 |
||
874 | 1061 |
displayObjectFor:anObject on:aDevice |
1062 |
"converts an object to a display object |
|
1063 |
" |
|
1572 | 1064 |
|obj s1 s2| |
874 | 1065 |
|
1066 |
obj := (anObject respondsTo:#displayObject) ifTrue:[anObject displayObject] |
|
1572 | 1067 |
ifFalse:[anObject]. |
874 | 1068 |
|
1069 |
obj isString ifTrue:[ |
|
1572 | 1070 |
^ obj |
874 | 1071 |
]. |
1072 |
||
1582 | 1073 |
MessageNotUnderstood |
1074 |
ignoreNotUnderstoodOf:#'onDevice:' |
|
1075 |
in:[ |
|
1076 |
obj := obj onDevice:aDevice |
|
1077 |
]. |
|
874 | 1078 |
|
1079 |
obj isImage ifTrue:[ |
|
1572 | 1080 |
^ obj clearMaskedPixels |
874 | 1081 |
]. |
1082 |
||
1083 |
obj class == LabelAndIcon ifTrue:[ |
|
1572 | 1084 |
obj image notNil ifTrue:[obj image clearMaskedPixels]. |
1085 |
obj icon notNil ifTrue:[obj icon clearMaskedPixels]. |
|
1823 | 1086 |
^ obj |
874 | 1087 |
]. |
1088 |
||
1089 |
(obj class == MultiColListEntry) ifFalse:[ |
|
1572 | 1090 |
^ obj |
874 | 1091 |
]. |
1092 |
s1 := obj colAt:1. |
|
1093 |
s2 := obj colAt:2. |
|
1094 |
||
1095 |
s1 isImage ifTrue:[ |
|
1572 | 1096 |
s2 isImage ifTrue:[ ^ self displayObjectFor:(LabelAndIcon form:s1 image:s2) on:aDevice ]. |
1097 |
s2 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s1 string:s2) on:aDevice ]. |
|
1098 |
^ (s1 on:aDevice) clearMaskedPixels |
|
874 | 1099 |
]. |
1100 |
||
1101 |
s2 isImage ifTrue:[ |
|
1572 | 1102 |
s1 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s2 string:s1) on:aDevice ]. |
1103 |
^ (s2 on:aDevice) clearMaskedPixels |
|
874 | 1104 |
]. |
1105 |
||
1106 |
s1 isString ifTrue:[^ s1]. |
|
1107 |
s2 isString ifTrue:[^ s2]. |
|
1823 | 1108 |
^ obj |
874 | 1109 |
! |
1110 |
||
397 | 1111 |
showDragging:items in:aView at:p |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1112 |
"helper for dragging dragObjects: draw them all" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1113 |
|
397 | 1114 |
|offs| |
1115 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1116 |
offs := 0. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1117 |
items do:[:item | |
1490
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
1118 |
item displayOn:aView at:p + (0@offs). |
b2e1f907060c
care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents:
1487
diff
changeset
|
1119 |
offs := offs + (item heightOn:self) |
397 | 1120 |
] |
1121 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1122 |
"Modified: 19.4.1997 / 12:41:24 / cg" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1123 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1124 |
|
341 | 1125 |
!DragAndDropManager methodsFor:'event catching'! |
1126 |
||
1686 | 1127 |
buttonMotion:button x:x y:y view:aView |
1128 |
|device screenPoint oldWg oldId oldPt newId newWg oldTgt newTgt isDroppable cursor| |
|
874 | 1129 |
|
1842
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1130 |
escapePressed == true ifTrue:[ |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1131 |
self removePassiveAction. |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1132 |
^ self |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1133 |
]. |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1134 |
|
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1135 |
(dragView notNil and:[dragView sensor motionEventPending]) ifTrue:[ |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1136 |
^ self |
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1137 |
]. |
1661
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
1138 |
self removePassiveAction. |
1619 | 1139 |
|
874 | 1140 |
device := dragView device. |
1141 |
oldWg := dropContext targetWidget. |
|
1142 |
oldId := dropContext targetId. |
|
1143 |
oldPt := dropContext rootPoint. |
|
1144 |
||
1686 | 1145 |
screenPoint := self class translatePointToScreen:(x @ y) from:aView. |
1146 |
"/ screenPoint := device pointerPosition. |
|
1511 | 1147 |
dropContext rootPoint:screenPoint. |
874 | 1148 |
|
1511 | 1149 |
newId := device viewIdFromPoint:screenPoint. |
874 | 1150 |
newWg := device viewFromId:newId. |
1686 | 1151 |
|
1152 |
dropContext rootPoint:screenPoint. |
|
874 | 1153 |
dropContext targetWidget:newWg id:newId. |
1154 |
||
1155 |
handler isInterestedInDropTarget ifFalse:[ |
|
1289 | 1156 |
"/ |
1157 |
"/ line or arrow handler |
|
1158 |
"/ |
|
1511 | 1159 |
handler dragTo:screenPoint. |
1289 | 1160 |
^ self |
874 | 1161 |
]. |
1686 | 1162 |
oldTgt := dropContext dropTarget. |
1163 |
newTgt := self doFindDropTargetIn:newWg at:screenPoint. |
|
874 | 1164 |
|
1686 | 1165 |
newTgt ~= oldTgt ifTrue:[ |
1289 | 1166 |
"/ |
1686 | 1167 |
"/ drop target changed: handler might restore the screen |
1168 |
"/ |
|
1169 |
handler dropTargetWillChange. |
|
341 | 1170 |
|
1686 | 1171 |
oldTgt notNil ifTrue:[ |
1172 |
"/ |
|
1173 |
"/ setup old context |
|
1174 |
"/ |
|
1175 |
dropContext targetWidget:oldWg id:oldId. |
|
1176 |
oldTgt leave:dropContext. |
|
1177 |
dropContext targetWidget:newWg id:newId. |
|
1178 |
]. |
|
1179 |
dropContext dropTarget:newTgt. |
|
1180 |
newTgt notNil ifTrue:[ newTgt enter:dropContext ] |
|
874 | 1181 |
] ifFalse:[ |
1686 | 1182 |
dropContext dropTarget:newTgt |
874 | 1183 |
]. |
1686 | 1184 |
|
874 | 1185 |
"/ |
1186 |
"/ update the cursor |
|
1187 |
"/ |
|
1686 | 1188 |
|
874 | 1189 |
(isDroppable := dropContext canDrop) ifTrue:[ |
1289 | 1190 |
cursor := enabledCursor |
874 | 1191 |
] ifFalse:[ |
1686 | 1192 |
dropContext isAlienView ifFalse:[cursor := disabledCursor] |
1193 |
ifTrue:[cursor := alienCursor] |
|
874 | 1194 |
]. |
1195 |
dragView cursor:cursor now:true. |
|
1196 |
"/ |
|
1197 |
"/ test if droppable state changed |
|
1198 |
"/ |
|
1199 |
canDrop == isDroppable ifFalse:[ |
|
1289 | 1200 |
"/ |
1201 |
"/ droppable state changed: handler might restore the screen |
|
1202 |
"/ |
|
1203 |
canDrop := isDroppable. |
|
1204 |
handler dropTargetWillChange |
|
874 | 1205 |
]. |
394 | 1206 |
|
874 | 1207 |
newTgt notNil ifTrue:[ newTgt over:dropContext ]. |
1511 | 1208 |
handler dragTo:screenPoint. |
874 | 1209 |
! |
394 | 1210 |
|
1686 | 1211 |
buttonRelease:button x:x y:y view:aView |
874 | 1212 |
|
1686 | 1213 |
((button == 1) or:[button == #select]) ifFalse:[ |
1619 | 1214 |
^ self |
874 | 1215 |
]. |
1686 | 1216 |
self removePassiveAction. |
1661
3092c6bac88e
added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
1217 |
|
1686 | 1218 |
restoreBlock value. "/ restore context before start drag |
394 | 1219 |
|
1686 | 1220 |
escapePressed ~~ true ifTrue:[ |
1619 | 1221 |
"/ |
1686 | 1222 |
"/ at least do the drop operation |
1619 | 1223 |
"/ |
1686 | 1224 |
dropAction isNil ifTrue:[ |
1225 |
dropContext doDrop |
|
1226 |
] ifFalse:[ |
|
1227 |
"/ |
|
1228 |
"/ initiator wants to do it himself, manually. |
|
1229 |
"/ Thus, no feedBack operation invoked. |
|
1230 |
"/ |
|
1231 |
dropAction value:(dropContext targetWidget) |
|
1232 |
value:(dropContext targetId) |
|
1233 |
value:(dropContext rootPoint) |
|
1234 |
value:(dropContext targetPoint). |
|
1235 |
]. |
|
1236 |
]. |
|
1289 | 1237 |
! |
1238 |
||
1685 | 1239 |
escapePressed |
1240 |
"handle key escape |
|
1241 |
" |
|
1242 |
|dropTarget| |
|
1243 |
||
1244 |
escapePressed ~~ true ifTrue:[ |
|
1245 |
escapePressed := true. |
|
1246 |
||
1247 |
handler notNil ifTrue:[ |
|
1248 |
"/ restore handler |
|
1249 |
dropTarget := dropContext dropTarget. |
|
1250 |
handler postDragging. |
|
1251 |
||
1252 |
dropTarget notNil ifTrue:[ |
|
1253 |
"/ invoke leave operation |
|
1254 |
dropTarget leave:dropContext. |
|
1255 |
dropContext dropTarget:nil. |
|
1256 |
]. |
|
1257 |
]. |
|
1258 |
]. |
|
1259 |
! |
|
1260 |
||
1686 | 1261 |
keyPress:aKey x:x y:y view:aView |
874 | 1262 |
|
1686 | 1263 |
escapePressed == true ifTrue:[ ^ self ]. "/ ignorred, escaped was pressed |
1629
9b0f45e63e24
bug fix if operation cancled by #Escape, must invoke #leave
ca
parents:
1619
diff
changeset
|
1264 |
|
9b0f45e63e24
bug fix if operation cancled by #Escape, must invoke #leave
ca
parents:
1619
diff
changeset
|
1265 |
aKey == #Escape ifTrue:[ |
1685 | 1266 |
self escapePressed. |
1619 | 1267 |
]. |
1686 | 1268 |
! |
1269 |
||
1834 | 1270 |
processAutoScroll |
1271 |
"process an autoScroll event |
|
1272 |
" |
|
1273 |
|targetWidget targetPoint| |
|
1274 |
||
1275 |
self isActive ifFalse:[^ self]. |
|
1276 |
||
1277 |
dropContext isNil ifTrue:[ ^ self ]. |
|
1278 |
||
1279 |
targetWidget := dropContext targetWidget. |
|
1280 |
targetWidget isNil ifTrue:[ ^ self ]. |
|
1835
d6db8466019b
bugfix in scrolling during drag & drop; test for isRootView
ca
parents:
1834
diff
changeset
|
1281 |
targetWidget isRootView ifTrue:[ ^ self ]. |
1834 | 1282 |
|
1283 |
targetPoint := dropContext targetPoint. |
|
1284 |
targetPoint isNil ifTrue:[ ^ self ]. |
|
1285 |
||
1286 |
(targetWidget dragAutoScroll: dropContext) ifFalse:[ |
|
1287 |
^ self |
|
1288 |
]. |
|
1289 |
self buttonMotion:256 x:(targetPoint x) y:(targetPoint y) view:targetWidget. |
|
1290 |
! |
|
1291 |
||
1686 | 1292 |
processEvent:event |
2022 | 1293 |
"filter keyboard events. |
1294 |
Return true, if I have eaten the event" |
|
1295 |
||
1686 | 1296 |
|evView| |
1297 |
||
1298 |
restoreBlock isNil ifTrue:[^ false]. "/ should not happen |
|
1299 |
||
1300 |
evView := event view. |
|
1301 |
evView isNil ifTrue:[^ false]. |
|
1302 |
||
1303 |
event isInputEvent ifFalse:[ |
|
1304 |
^ false |
|
1305 |
]. |
|
1306 |
||
1307 |
event isKeyEvent ifTrue:[ |
|
1308 |
self keyPress:(event key) x:(event x) y:(event y) view:evView. |
|
1309 |
^ true |
|
1310 |
]. |
|
1311 |
||
1312 |
event isButtonMotionEvent ifTrue:[ |
|
1313 |
self buttonMotion:(event state) x:(event x) y:(event y) view:evView. |
|
1314 |
] ifFalse:[ |
|
1315 |
event isButtonReleaseEvent ifTrue:[ |
|
1316 |
self buttonRelease:(event button) x:(event x) y:(event y) view:evView. |
|
1317 |
] |
|
1318 |
]. |
|
1319 |
^ true |
|
874 | 1320 |
! ! |
1321 |
||
1322 |
!DragAndDropManager methodsFor:'initialization'! |
|
341 | 1323 |
|
874 | 1324 |
initialize |
1325 |
super initialize. |
|
394 | 1326 |
|
874 | 1327 |
dragOffset := 0 @ 0. |
1328 |
dropContext := DropContext new. |
|
1618 | 1329 |
dropContext manager:self. |
874 | 1330 |
alienCursor := Cursor questionMark. |
1331 |
enabledCursor := Cursor thumbsUp. |
|
1332 |
disabledCursor := Cursor thumbsDown. |
|
1333 |
canDrop := false. |
|
341 | 1334 |
! ! |
1335 |
||
1336 |
!DragAndDropManager methodsFor:'private'! |
|
1337 |
||
874 | 1338 |
doDrop:aContext in:aWidget |
1339 |
"old drop mechanism |
|
1340 |
" |
|
1341 |
|point| |
|
628 | 1342 |
|
1511 | 1343 |
DragContextQuerySignal answer:aContext do:[ |
1344 |
DragOriginatorQuerySignal answer:dragView do:[ |
|
1345 |
DragOffsetQuerySignal answer:dragOffset do:[ |
|
1346 |
aContext targetWidget == aWidget ifTrue:[ |
|
1347 |
point := aContext targetPoint |
|
1348 |
] ifFalse:[ |
|
1349 |
point := 0@0. "/ nil. |
|
1350 |
"/ |
|
1351 |
"/ FeedBack: set the widget which handles the drop |
|
1352 |
"/ |
|
1353 |
aContext targetWidget:aWidget id:(aWidget id). |
|
1354 |
]. |
|
1355 |
aWidget drop:(aContext dropObjects) at:point |
|
1356 |
] |
|
1357 |
]. |
|
609
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1358 |
]. |
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1359 |
|
1072
be90bc383d83
do not pas nil point to dropDestination
Claus Gittinger <cg@exept.de>
parents:
881
diff
changeset
|
1360 |
"Modified: / 11.9.1998 / 00:53:22 / cg" |
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
1361 |
! |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
1362 |
|
874 | 1363 |
doFindDropTargetIn:aView at:aPoint |
1364 |
"get the drop target for a view and source at a point or nil |
|
411 | 1365 |
" |
628 | 1366 |
|
874 | 1367 |
aView isNil ifTrue:[ ^ nil ]. |
1582 | 1368 |
|
874 | 1369 |
"/ |
1370 |
"/ new mechanism to get a dropTarget |
|
1371 |
"/ |
|
1587 | 1372 |
|
1582 | 1373 |
MessageNotUnderstood |
1374 |
ignoreNotUnderstoodOf:#dropTarget |
|
1587 | 1375 |
in:[ |target| |
1582 | 1376 |
target := aView dropTarget. |
1587 | 1377 |
target notNil ifTrue:[ ^ target ]. |
1582 | 1378 |
]. |
1379 |
||
874 | 1380 |
"/ |
1381 |
"/ old mechanism to get a dropTarget |
|
1382 |
"/ |
|
628 | 1383 |
|
1511 | 1384 |
DragContextQuerySignal answer:dropContext do:[ |
1385 |
DragOriginatorQuerySignal answer:dragView do:[ |
|
1386 |
DragOffsetQuerySignal answer:dragOffset do:[ |
|
1587 | 1387 |
|view dobj| |
1388 |
||
1389 |
view := aView. |
|
1390 |
dobj := dropContext dropObjects. |
|
1391 |
[ |
|
1392 |
(view canDrop:dobj) ifTrue:[ |
|
1511 | 1393 |
^ DropTarget receiver:self argument:view dropSelector:#doDrop:in:. |
1394 |
]. |
|
1395 |
(view := view superView) notNil |
|
1396 |
] whileTrue. |
|
1397 |
] |
|
1398 |
]. |
|
874 | 1399 |
]. |
1400 |
^ nil |
|
1401 |
! |
|
628 | 1402 |
|
874 | 1403 |
doStart:aHandler for:aView atEnd:aFourArgEndBlock |
1404 |
"setup a handler and a restore block |
|
628 | 1405 |
" |
1749
1f58fbcd4b96
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
1718
diff
changeset
|
1406 |
|device lastActive windowGroup savedCursor screenPoint| |
628 | 1407 |
|
1512 | 1408 |
device := aView device. |
1685 | 1409 |
lastActive := ActiveDragAndDropManagers at:device ifAbsent:nil. |
1410 |
||
1411 |
lastActive notNil ifTrue:[ |
|
1412 |
"/ self error:'oops - two dnd managers active' mayProceed:true. |
|
1413 |
||
1414 |
lastActive forceGiveUp. |
|
1939 | 1415 |
'DragAndDropManager [info]: oops - two dnd managers active' infoPrintCR. |
1487 | 1416 |
]. |
1512 | 1417 |
ActiveDragAndDropManagers at:device put:self. |
1487 | 1418 |
|
874 | 1419 |
dropContext sourceWidget:aView. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1420 |
|
874 | 1421 |
dragOffset isNil ifTrue:[ dragOffset := 0 @ 0 ]. |
1422 |
alienCursor isNil ifTrue:[ alienCursor := disabledCursor ]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1423 |
|
1686 | 1424 |
dragView := aView. |
1425 |
dropAction := aFourArgEndBlock. |
|
1426 |
windowGroup := aView windowGroup. |
|
1619 | 1427 |
handler := aHandler. |
1428 |
escapePressed := false. |
|
609
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1429 |
|
1162
0539b64679ce
set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1430 |
dropContext dragHandler:aHandler. |
1686 | 1431 |
|
1689
5aae4c617ffd
obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents:
1686
diff
changeset
|
1432 |
savedCursor := dragView cursor. |
5aae4c617ffd
obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents:
1686
diff
changeset
|
1433 |
windowGroup addPreEventHook:self. |
5aae4c617ffd
obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents:
1686
diff
changeset
|
1434 |
windowGroup addPostEventHook:self. |
1162
0539b64679ce
set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1435 |
|
874 | 1436 |
restoreBlock := [ |
1686 | 1437 |
restoreBlock := nil. |
1438 |
||
1834 | 1439 |
autoScrollTask notNil ifTrue:[ |
1440 |
autoScrollTask terminate. |
|
1441 |
autoScrollTask := nil. |
|
1442 |
]. |
|
1443 |
||
1512 | 1444 |
ActiveDragAndDropManagers removeKey:device ifAbsent:nil. |
1686 | 1445 |
escapePressed ifFalse:[ aHandler postDragging ]. |
1446 |
||
1689
5aae4c617ffd
obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents:
1686
diff
changeset
|
1447 |
windowGroup removePreEventHook:self. |
5aae4c617ffd
obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents:
1686
diff
changeset
|
1448 |
windowGroup removePostEventHook:self. |
5aae4c617ffd
obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents:
1686
diff
changeset
|
1449 |
dragView cursor:savedCursor. |
874 | 1450 |
]. |
1686 | 1451 |
aHandler preDraggingIn:dragView. |
1289 | 1452 |
|
1453 |
"/ must wait for all pending motion events to arrive, and ignore them |
|
1749
1f58fbcd4b96
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
1718
diff
changeset
|
1454 |
device sync. |
1f58fbcd4b96
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
1718
diff
changeset
|
1455 |
dragView sensor flushMotionEventsFor:nil. |
1289 | 1456 |
|
1834 | 1457 |
autoScrollTask := Process for:[ |
1458 |
[ |sensor| |
|
1459 |
||
1460 |
sensor := windowGroup sensor. |
|
1461 |
||
1462 |
[ self isActive ] whileTrue:[ |
|
1842
f033c7b344de
compress buttonMotion events handling (look for outstanding events)
ca
parents:
1835
diff
changeset
|
1463 |
Delay waitForMilliseconds:(self class autoScrollDelayTimeMs). |
1834 | 1464 |
|
1465 |
self isActive ifTrue:[ |
|
1466 |
sensor pushUserEvent:#processAutoScroll for:self. |
|
1467 |
]. |
|
1468 |
]. |
|
1469 |
]ensure:[ |
|
1470 |
autoScrollTask := nil. |
|
1471 |
] |
|
1472 |
] priority:(Processor userSchedulingPriority). |
|
1473 |
||
1474 |
autoScrollTask name:'Drag-AutoScroll'. |
|
1475 |
autoScrollTask resume. |
|
1476 |
||
1289 | 1477 |
"/ start with a first draw at the current mouse position |
1686 | 1478 |
screenPoint := device pointerPosition. |
1479 |
self buttonMotion:1 x:(screenPoint x) y:(screenPoint y) view:(device rootView). |
|
1487 | 1480 |
! |
1481 |
||
1685 | 1482 |
forceGiveUp |
1483 |
"called if the DragAndDropManager no longer should be |
|
1484 |
active; a second one is started |
|
1485 |
" |
|
1486 |
self escapePressed. |
|
1487 |
self removePassiveAction. |
|
1488 |
restoreBlock value. |
|
1489 |
! |
|
1490 |
||
1834 | 1491 |
isActive |
1492 |
"returns true if a drag operation is active |
|
1493 |
" |
|
1494 |
restoreBlock isNil ifTrue:[ ^ false ]. |
|
1495 |
^ escapePressed ~~ true |
|
1496 |
! |
|
1497 |
||
1487 | 1498 |
saveDraw:aBlock |
1499 |
handler postDragging. |
|
1500 |
aBlock value. |
|
1638 | 1501 |
|
1502 |
escapePressed == true ifFalse:[ |
|
1503 |
"/ reread and show drag items |
|
1504 |
handler rereadSaveArea. |
|
1505 |
handler restoreFromSaveArea. |
|
1506 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1507 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1508 |
|
341 | 1509 |
!DragAndDropManager class methodsFor:'documentation'! |
1510 |
||
1511 |
version |
|
2022 | 1512 |
^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.58 2004-11-11 09:14:01 cg Exp $' |
341 | 1513 |
! ! |
1629
9b0f45e63e24
bug fix if operation cancled by #Escape, must invoke #leave
ca
parents:
1619
diff
changeset
|
1514 |
|
628 | 1515 |
DragAndDropManager initialize! |