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