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