author | Claus Gittinger <cg@exept.de> |
Thu, 27 Feb 2020 16:08:38 +0100 | |
changeset 4457 | 8c328436fba9 |
parent 4440 | 7ad4e1da35ce |
permissions | -rw-r--r-- |
4439 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
6 | 4 |
COPYRIGHT (c) 1990 by Claus Gittinger |
99 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2250 | 14 |
"{ Package: 'stx:libview2' }" |
0 | 15 |
|
3772 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
65 | 18 |
SimpleView subclass:#InputView |
225 | 19 |
instanceVariableNames:'eventReceiver' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
235 | 22 |
category:'Views-Special' |
0 | 23 |
! |
24 |
||
449 | 25 |
!InputView class methodsFor:'documentation'! |
21 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
99 | 30 |
All Rights Reserved |
0 | 31 |
|
21 | 32 |
This software is furnished under a license and may be used |
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
0 | 40 |
|
21 | 41 |
documentation |
42 |
" |
|
43 |
a view for input only - forwarding all events to another object. |
|
3772 | 44 |
This kind of view can be used to be laid on top of another view to catch all |
21 | 45 |
input. (Interface builder) |
4439 | 46 |
NOTICE: the event forwarding is a leftover from times when no delegation mechanism |
225 | 47 |
existed - it will vanish - use delegates for new code. |
48 |
||
4440 | 49 |
[caveat:] |
50 |
do not use |
|
51 |
it seems to (no longer) work on the desktop (at least with win10). |
|
52 |
||
225 | 53 |
[author:] |
54 |
Claus Gittinger |
|
21 | 55 |
" |
4440 | 56 |
! |
57 |
||
58 |
examples |
|
59 |
" |
|
60 |
|v| |
|
61 |
||
62 |
v := InputView origin:0@0 extent:Display extent. |
|
63 |
[Delay waitForSeconds:5. v destroy] fork. |
|
64 |
v open. |
|
65 |
" |
|
21 | 66 |
! ! |
0 | 67 |
|
130 | 68 |
!InputView methodsFor:'accessing'! |
0 | 69 |
|
130 | 70 |
eventReceiver:aView |
1241 | 71 |
"set the view to which input events are forwarded" |
72 |
||
130 | 73 |
eventReceiver := aView |
74 |
! |
|
0 | 75 |
|
286
b7f2e2aefae1
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
76 |
isInputOnly |
1241 | 77 |
"return true, since this is a transparent input-only view" |
286
b7f2e2aefae1
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
78 |
|
0 | 79 |
^ true |
286
b7f2e2aefae1
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
80 |
|
b7f2e2aefae1
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
81 |
"Created: 1.6.1996 / 13:22:31 / cg" |
21 | 82 |
! ! |
83 |
||
449 | 84 |
!InputView methodsFor:'drag & drop'! |
85 |
||
2257 | 86 |
canDrop:aDropContext |
87 |
"return true, if aCollectionOfDropObjects can be dropped here. |
|
88 |
Delegated to my eventReceiving view" |
|
89 |
||
90 |
^ eventReceiver notNil |
|
91 |
and:[ eventReceiver canDrop:aDropContext ] |
|
92 |
||
93 |
"Created: / 13-10-2006 / 12:35:07 / cg" |
|
94 |
"Modified: / 13-10-2006 / 16:02:45 / cg" |
|
95 |
! |
|
96 |
||
97 |
canDrop:aDropContext at:aPoint |
|
1241 | 98 |
"return true, if aCollectionOfDropObjects can be dropped here. |
99 |
Delegated to my eventReceiving view" |
|
100 |
||
2257 | 101 |
^ eventReceiver notNil |
102 |
and:[ eventReceiver canDrop:aDropContext at:aPoint ] |
|
449 | 103 |
|
2257 | 104 |
"Created: / 13-10-2006 / 12:35:07 / cg" |
105 |
"Modified: / 13-10-2006 / 16:02:37 / cg" |
|
449 | 106 |
! |
107 |
||
2257 | 108 |
canDropObjects:aCollectionOfDropObjects |
109 |
"return true, if aCollectionOfDropObjects can be dropped here. |
|
110 |
Delegated to my eventReceiving view" |
|
111 |
||
112 |
^ eventReceiver notNil |
|
113 |
and:[ eventReceiver canDropObjects:aCollectionOfDropObjects ] |
|
114 |
||
115 |
"Created: / 13-10-2006 / 16:01:58 / cg" |
|
116 |
! |
|
117 |
||
118 |
canDropObjects:aCollectionOfDropObjects at:aPoint |
|
2250 | 119 |
"return true, if aCollectionOfDropObjects can be dropped here. |
120 |
Delegated to my eventReceiving view" |
|
121 |
||
2257 | 122 |
^ eventReceiver notNil |
123 |
and:[ eventReceiver canDropObjects:aCollectionOfDropObjects at:aPoint] |
|
2250 | 124 |
|
2257 | 125 |
"Created: / 13-10-2006 / 16:02:13 / cg" |
2250 | 126 |
! |
127 |
||
2257 | 128 |
drop:aDropContext |
129 |
"drop aCollectionOfDropObjects here. |
|
130 |
Delegated to my eventReceiving view" |
|
131 |
||
132 |
eventReceiver drop:aDropContext |
|
133 |
||
134 |
"Modified: / 13-10-2006 / 16:03:32 / cg" |
|
135 |
! |
|
136 |
||
137 |
drop:aDropContext at:aPoint |
|
2250 | 138 |
"drop aCollectionOfDropObjects here. |
139 |
Delegated to my eventReceiving view" |
|
140 |
||
2257 | 141 |
eventReceiver drop:aDropContext at:aPoint |
2250 | 142 |
|
2257 | 143 |
"Modified: / 13-10-2006 / 16:03:27 / cg" |
2250 | 144 |
! |
145 |
||
2257 | 146 |
dropObjects:aCollectionOfDropObjects |
1241 | 147 |
"drop aCollectionOfDropObjects here. |
148 |
Delegated to my eventReceiving view" |
|
149 |
||
2257 | 150 |
eventReceiver dropObjects:aCollectionOfDropObjects |
151 |
||
152 |
"Created: / 13-10-2006 / 16:03:05 / cg" |
|
153 |
! |
|
449 | 154 |
|
2257 | 155 |
dropObjects:aCollectionOfDropObjects at:aPoint |
156 |
"drop aCollectionOfDropObjects here. |
|
157 |
Delegated to my eventReceiving view" |
|
158 |
||
159 |
eventReceiver dropObjects:aCollectionOfDropObjects at:aPoint |
|
160 |
||
161 |
"Created: / 13-10-2006 / 16:03:12 / cg" |
|
449 | 162 |
! ! |
163 |
||
0 | 164 |
!InputView methodsFor:'event handling'! |
165 |
||
130 | 166 |
buttonMotion:state x:x y:y |
1241 | 167 |
"redefined to forward the event to my eventReceiver" |
21 | 168 |
|
0 | 169 |
eventReceiver notNil ifTrue:[ |
1185
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
170 |
eventReceiver buttonMotion:state x:x y:y |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
171 |
] ifFalse:[ |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
172 |
super buttonMotion:state x:x y:y |
0 | 173 |
] |
174 |
! |
|
175 |
||
176 |
buttonPress:button x:x y:y |
|
1241 | 177 |
"redefined to forward the event to my eventReceiver" |
21 | 178 |
|
0 | 179 |
eventReceiver notNil ifTrue:[ |
1185
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
180 |
eventReceiver buttonPress:button x:x y:y |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
181 |
] ifFalse:[ |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
182 |
super buttonPress:button x:x y:y |
0 | 183 |
] |
184 |
! |
|
185 |
||
186 |
buttonRelease:button x:x y:y |
|
1241 | 187 |
"redefined to forward the event to my eventReceiver" |
21 | 188 |
|
0 | 189 |
eventReceiver notNil ifTrue:[ |
1185
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
190 |
eventReceiver buttonRelease:button x:x y:y |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
191 |
] ifFalse:[ |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
192 |
super buttonRelease:button x:x y:y |
0 | 193 |
] |
194 |
! |
|
195 |
||
130 | 196 |
exposeX:x y:y width:w height:h |
1241 | 197 |
"dummy - will never be received" |
198 |
||
130 | 199 |
^ self |
200 |
! |
|
201 |
||
0 | 202 |
focusIn |
1241 | 203 |
"redefined to forward the event to my eventReceiver" |
21 | 204 |
|
0 | 205 |
eventReceiver notNil ifTrue:[ |
1241 | 206 |
eventReceiver focusIn |
0 | 207 |
] |
208 |
! |
|
209 |
||
210 |
focusOut |
|
1241 | 211 |
"redefined to forward the event to my eventReceiver" |
21 | 212 |
|
0 | 213 |
eventReceiver notNil ifTrue:[ |
1241 | 214 |
eventReceiver focusOut |
0 | 215 |
] |
216 |
! |
|
217 |
||
130 | 218 |
keyPress:key x:x y:y |
1241 | 219 |
"redefined to forward the event to my eventReceiver" |
130 | 220 |
|
221 |
eventReceiver notNil ifTrue:[ |
|
1185
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
222 |
eventReceiver keyPress:key x:x y:y |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
223 |
] ifFalse:[ |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
224 |
super keyPress:key x:x y:y |
130 | 225 |
] |
226 |
! |
|
227 |
||
228 |
keyRelease:key x:x y:y |
|
1241 | 229 |
"redefined to forward the event to my eventReceiver" |
130 | 230 |
|
231 |
eventReceiver notNil ifTrue:[ |
|
1185
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
232 |
eventReceiver keyRelease:key x:x y:y |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
233 |
] ifFalse:[ |
522d9c84f0a9
fix: if no delegate, perform normal (superclass)
Claus Gittinger <cg@exept.de>
parents:
521
diff
changeset
|
234 |
super keyRelease:key x:x y:y |
130 | 235 |
] |
236 |
! |
|
237 |
||
0 | 238 |
pointerEnter:state x:x y:y |
1241 | 239 |
"redefined to forward the event to my eventReceiver" |
21 | 240 |
|
0 | 241 |
eventReceiver notNil ifTrue:[ |
1241 | 242 |
eventReceiver pointerEnter:state x:x y:y |
0 | 243 |
] |
244 |
! |
|
245 |
||
246 |
pointerLeave:state |
|
1241 | 247 |
"redefined to forward the event to my eventReceiver" |
21 | 248 |
|
0 | 249 |
eventReceiver notNil ifTrue:[ |
1241 | 250 |
eventReceiver pointerLeave:state |
0 | 251 |
] |
252 |
! ! |
|
130 | 253 |
|
254 |
!InputView methodsFor:'initialization'! |
|
255 |
||
256 |
initialize |
|
257 |
super initialize. |
|
2775 | 258 |
self borderWidth:0 |
130 | 259 |
! ! |
260 |
||
261 |
!InputView methodsFor:'redefined dummy'! |
|
262 |
||
263 |
setViewBackground |
|
1241 | 264 |
"dummy - inputviews have no background" |
130 | 265 |
|
266 |
^ self |
|
267 |
! ! |
|
268 |
||
449 | 269 |
!InputView class methodsFor:'documentation'! |
130 | 270 |
|
271 |
version |
|
3772 | 272 |
^ '$Header$' |
2772
71336ba2fc96
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
273 |
! |
71336ba2fc96
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
274 |
|
71336ba2fc96
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
275 |
version_CVS |
3772 | 276 |
^ '$Header$' |
130 | 277 |
! ! |
3772 | 278 |