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