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