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