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