author | Claus Gittinger <cg@exept.de> |
Thu, 19 Dec 2019 21:08:53 +0100 | |
changeset 8951 | fddd874a2251 |
parent 8362 | 573b5a8cc1c5 |
permissions | -rw-r--r-- |
8362 | 1 |
"{ Encoding: utf8 }" |
2 |
||
128 | 3 |
" |
4 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
5 |
All Rights Reserved |
|
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 |
" |
|
3682 | 14 |
"{ Package: 'stx:libview' }" |
15 |
||
7660 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
128 | 18 |
Object subclass:#KeyboardForwarder |
400 | 19 |
instanceVariableNames:'sourceView destinationView destination condition filter' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
5277 | 22 |
category:'Interface-Support-UI' |
128 | 23 |
! |
24 |
||
25 |
!KeyboardForwarder class methodsFor:'documentation'! |
|
26 |
||
244 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
30 |
All Rights Reserved |
|
31 |
||
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 |
||
128 | 40 |
! |
41 |
||
42 |
documentation |
|
43 |
" |
|
144 | 44 |
Instances of this class can be used to forward keyboard |
45 |
events to some object or other view (install them via aView delegate:). |
|
46 |
Event delegation allows to add additional keyboard functions to views |
|
47 |
WITHOUT modifying their code or changing controllers. |
|
48 |
Also, it allows to catch certain individual keys to ignore them or |
|
49 |
perform different functions. |
|
50 |
||
7660 | 51 |
Notice, that delegates don't have to be instances of |
128 | 52 |
myself; any object with a protocol similar to mine can be used as |
53 |
a delegate. |
|
142 | 54 |
(i.e. any object that responds to |
55 |
handlesKeyPress:view: / keyPress:x:y:view: / delegatesTo: etc.) |
|
139 | 56 |
|
57 |
However, I provide the most common functions required for conditional |
|
58 |
event delegation and instances of myself are for example used to forward |
|
59 |
events from elements of some dialogBoxes to the enterfield/fieldGroup - |
|
144 | 60 |
(which allows keyboard input to be forwarded to the active text-field even |
61 |
while the mouse pointer is somewhere else) |
|
139 | 62 |
|
63 |
Another application of delegation is to catch keyboard input to some standard |
|
64 |
widget, optionally processing and resending the key-event. |
|
128 | 65 |
|
144 | 66 |
I can either forward the key event to another view, or to some general |
67 |
object - the difference is that views are sent a #keyXXX:x:y: message, |
|
68 |
while general destinations get a #keyXXX:x:y:view: message, with the original |
|
69 |
view (the one in which the event occurred) as additional argument. |
|
70 |
||
598 | 71 |
[Instance Variables:] |
139 | 72 |
|
598 | 73 |
destinationView <View> the view which shall receive |
74 |
the forwarded keyboard events. |
|
134 | 75 |
|
598 | 76 |
destination <Object> the object which shall receive |
77 |
the forwarded keyboard events. |
|
139 | 78 |
|
598 | 79 |
sourceView <ViewOrNil> if non-nil, only events from this |
80 |
view are forwarded. |
|
81 |
(currently nowhere used) |
|
134 | 82 |
|
598 | 83 |
condition <Symbol> an additional condition for forwarding |
84 |
currently only #noFocus is implemented. |
|
85 |
The #noFocus condition will only forward |
|
86 |
events if no explicit focus has been |
|
87 |
set in the windowGroup. |
|
144 | 88 |
|
598 | 89 |
<Block> condition block - event is forwarded, |
90 |
if it evaluates to true. |
|
91 |
The block gets 3 arguments: |
|
92 |
eventType #keyPress or #keyRelease |
|
93 |
key the key |
|
94 |
view the originating view |
|
144 | 95 |
|
96 |
For more info on event handling/forwarding, see the documentation in |
|
97 |
WindowSensor, WindowGroup and especially in WindowEvent. |
|
598 | 98 |
|
99 |
[see also:] |
|
100 |
WindowEvent WindowSensor WindowGroup |
|
612 | 101 |
|
102 |
[author:] |
|
103 |
Claus Gittinger |
|
144 | 104 |
" |
105 |
! |
|
106 |
||
107 |
examples |
|
108 |
" |
|
109 |
catch an enterfields input: |
|
620 | 110 |
[exBegin] |
111 |
|top field forwarder catcher| |
|
144 | 112 |
|
620 | 113 |
catcher := Plug new. |
114 |
catcher respondTo:#keyPress:x:y:view: |
|
1752 | 115 |
with:[:key :x :y :view | Transcript showCR:'caught keyPress: ' , key printString.]. |
620 | 116 |
catcher respondTo:#keyRelease:x:y:view: |
1752 | 117 |
with:[:key :x :y :view | Transcript showCR:'caught keyRelease: ' , key printString.]. |
144 | 118 |
|
620 | 119 |
top := StandardSystemView new. |
120 |
top extent:200@200. |
|
121 |
||
122 |
field := EditField in:top. |
|
123 |
field origin:0.0@0.0; width:1.0. |
|
144 | 124 |
|
620 | 125 |
forwarder := KeyboardForwarder to:catcher. |
126 |
field delegate:forwarder. |
|
144 | 127 |
|
620 | 128 |
top open |
129 |
[exEnd] |
|
144 | 130 |
|
131 |
||
132 |
catch an enterfields return-key only: |
|
620 | 133 |
[exBegin] |
134 |
|top field forwarder catcher| |
|
144 | 135 |
|
620 | 136 |
catcher := Plug new. |
137 |
catcher respondTo:#keyPress:x:y:view: |
|
1752 | 138 |
with:[:key :x :y :view | Transcript showCR:'caught return']. |
144 | 139 |
|
620 | 140 |
top := StandardSystemView new. |
141 |
top extent:200@200. |
|
144 | 142 |
|
620 | 143 |
field := EditField in:top. |
144 |
field origin:0.0@0.0; width:1.0. |
|
144 | 145 |
|
620 | 146 |
forwarder := KeyboardForwarder |
147 |
to:catcher |
|
148 |
condition:[:type :key :view | (type == #keyPress) & (key == #Return)]. |
|
149 |
field delegate:forwarder. |
|
144 | 150 |
|
620 | 151 |
top open |
152 |
[exEnd] |
|
144 | 153 |
|
154 |
||
155 |
catch all of an enterfields input and ignore it: |
|
620 | 156 |
[exBegin] |
157 |
|top field forwarder| |
|
144 | 158 |
|
620 | 159 |
top := StandardSystemView new. |
160 |
top extent:200@200. |
|
144 | 161 |
|
620 | 162 |
field := EditField in:top. |
163 |
field origin:0.0@0.0; width:1.0. |
|
144 | 164 |
|
620 | 165 |
forwarder := KeyboardForwarder to:nil. |
166 |
field delegate:forwarder. |
|
144 | 167 |
|
620 | 168 |
top open |
169 |
[exEnd] |
|
128 | 170 |
" |
171 |
! ! |
|
172 |
||
173 |
!KeyboardForwarder class methodsFor:'instance creation'! |
|
174 |
||
139 | 175 |
from:sourceView to:destination |
176 |
"create and return a new KeyboardForwarder to redirect key events |
|
177 |
for sourceView to destination. Events from other than the sourceView |
|
178 |
will not be forwarded. The forwarded event will be reported including |
|
8362 | 179 |
the original view as argument (i.e. as #keyPress:x:y:view:). |
180 |
||
139 | 181 |
Use this, if the destination is not a view." |
182 |
||
183 |
^ self new sourceView:sourceView; destination:destination |
|
184 |
! |
|
185 |
||
244 | 186 |
from:sourceView toView:destinationView |
187 |
"create and return a new KeyboardForwarder to redirect key events |
|
188 |
for sourceView to destinationView. Events from other than the sourceView |
|
189 |
will not be forwarded. The forwarded event will be reported excluding |
|
139 | 190 |
the original view as argument (i.e. as #keyPress:x:y:). |
8362 | 191 |
|
139 | 192 |
Use this, if the destination is a view." |
193 |
||
244 | 194 |
^ self new sourceView:sourceView; destinationView:destinationView |
134 | 195 |
! |
196 |
||
139 | 197 |
to:destination |
198 |
"create and return a new KeyboardForwarder to redirect any key event |
|
8362 | 199 |
to destination (independent of the view in which the event originally |
139 | 200 |
occurred). The forwarded event will be reported including |
201 |
the original view as argument (i.e. as #keyPress:x:y:view:). |
|
8362 | 202 |
|
139 | 203 |
Use this, if the destination is not a view." |
204 |
||
400 | 205 |
^ self to:destination condition:nil filter:nil |
139 | 206 |
! |
207 |
||
244 | 208 |
to:destination condition:aCondition |
209 |
"create and return a new KeyboardForwarder to redirect any key event |
|
8362 | 210 |
to destination |
211 |
(independent of the view in which the event originally occurred) |
|
212 |
but only, if some condition as specified by aCondition |
|
244 | 213 |
is met. The forwarded event will be reported including |
8362 | 214 |
the original view as argument (i.e. as #keyPress:x:y:view:). |
215 |
||
244 | 216 |
Use this, if the destination is not a view." |
217 |
||
400 | 218 |
^ self to:destination condition:aCondition filter:nil |
219 |
! |
|
220 |
||
221 |
to:destination condition:aCondition filter:aFilterBlock |
|
222 |
"create and return a new KeyboardForwarder to redirect any key event |
|
8362 | 223 |
to destination |
224 |
(independent of the view in which the event originally occurred) |
|
225 |
but only, if some condition as specified by aCondition |
|
400 | 226 |
is met and aFilterBlock returns true for that key. |
227 |
The forwarded event will be reported including |
|
228 |
the original view as argument (i.e. as #keyPress:x:y:view:). |
|
8362 | 229 |
|
400 | 230 |
Use this, if the destination is not a view." |
231 |
||
232 |
^ self new destination:destination; condition:aCondition; filter:aFilterBlock |
|
244 | 233 |
! |
234 |
||
235 |
toView:destinationView |
|
236 |
"create and return a new KeyboardForwarder to redirect any key event |
|
8362 | 237 |
to destinationView |
238 |
(independent of the view in which the event originally occurred). |
|
239 |
The forwarded event will be reported excluding |
|
240 |
the original view as argument (i.e. as #keyPress:x:y:). |
|
241 |
||
244 | 242 |
Use this, if the destination is a view." |
243 |
||
400 | 244 |
^ self toView:destinationView condition:nil filter:nil |
244 | 245 |
! |
246 |
||
144 | 247 |
toView:destinationView condition:aCondition |
139 | 248 |
"create and return a new KeyboardForwarder to redirect any key event |
8362 | 249 |
to destinationView |
250 |
(independent of the view in which the event originally occurred) but only, |
|
251 |
if some condition as specified by aCondition |
|
139 | 252 |
is met. The forwarded event will be reported excluding |
8362 | 253 |
the original view as argument (i.e. as #keyPress:x:y:). |
254 |
||
139 | 255 |
Use this, if the destination is a view." |
256 |
||
400 | 257 |
^ self toView:destinationView condition:aCondition filter:nil |
258 |
! |
|
259 |
||
260 |
toView:destinationView condition:aCondition filter:aFilterBlock |
|
261 |
"create and return a new KeyboardForwarder to redirect any key event |
|
8362 | 262 |
to destinationView |
263 |
(independent of the view in which the event originally occurred) |
|
264 |
but only, if some condition as specified by aCondition |
|
400 | 265 |
is met and aFilterBlock returns true for that key. |
266 |
The forwarded event will be reported excluding |
|
267 |
the original view as argument (i.e. as #keyPress:x:y:). |
|
8362 | 268 |
|
400 | 269 |
Use this, if the destination is a view." |
270 |
||
271 |
^ self new destinationView:destinationView; condition:aCondition; filter:aFilterBlock |
|
128 | 272 |
! ! |
273 |
||
144 | 274 |
!KeyboardForwarder methodsFor:'accessing'! |
128 | 275 |
|
134 | 276 |
condition:aCondition |
144 | 277 |
"set the condition - typically a block" |
278 |
||
134 | 279 |
condition := aCondition |
280 |
! |
|
281 |
||
244 | 282 |
destination |
283 |
"return the destination" |
|
144 | 284 |
|
244 | 285 |
^ destination |
139 | 286 |
! |
287 |
||
288 |
destination:anObject |
|
144 | 289 |
"set the destination |
290 |
- that one will get the event with an additional view arg." |
|
291 |
||
139 | 292 |
destination := anObject |
293 |
! |
|
294 |
||
244 | 295 |
destinationView |
296 |
"return the destination view" |
|
144 | 297 |
|
244 | 298 |
^ destinationView |
139 | 299 |
! |
300 |
||
244 | 301 |
destinationView:aView |
302 |
"set the destination view" |
|
144 | 303 |
|
244 | 304 |
destinationView := aView |
128 | 305 |
! |
306 |
||
400 | 307 |
filter:aOneArgBlock |
308 |
"set the filter - if non-nil, only keys for which it returns true are forwarded" |
|
309 |
||
310 |
filter := aOneArgBlock |
|
311 |
||
312 |
"Created: 4.2.1996 / 20:35:15 / cg" |
|
313 |
! |
|
314 |
||
128 | 315 |
sourceView |
144 | 316 |
"get the sourceView - if nonNil, only events from this view will be forwarded" |
317 |
||
128 | 318 |
^ sourceView |
142 | 319 |
! |
320 |
||
244 | 321 |
sourceView:aView |
322 |
"set the sourceView - if nonNil, only events from this view will be forwarded" |
|
128 | 323 |
|
244 | 324 |
sourceView := aView |
128 | 325 |
! ! |
326 |
||
327 |
!KeyboardForwarder methodsFor:'event forwarding'! |
|
328 |
||
329 |
keyPress:key x:x y:y view:aView |
|
139 | 330 |
"handle a delegated event - this is sent by the sensor to actually |
331 |
forward the event (i.e. after I returned true on handlesKeyPress:. |
|
332 |
Take care of cyclic delegation (via a kludge-test for negative coordinate)." |
|
333 |
||
3094 | 334 |
|xDel yDel forwardedEvent| |
1967
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
335 |
|
490
1d2ed059a063
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
336 |
x isNil ifTrue:[ |
400 | 337 |
" |
338 |
already delegated ... ignore |
|
339 |
" |
|
340 |
^ self |
|
341 |
]. |
|
342 |
||
343 |
filter notNil ifTrue:[ |
|
344 |
(filter value:key) ifFalse:[^ self]. |
|
128 | 345 |
]. |
346 |
||
1967
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
347 |
xDel := x. |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
348 |
yDel := y. |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
349 |
|
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
350 |
x == 0 ifTrue:[ |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
351 |
" |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
352 |
already delegated ... care to not delegate twice |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
353 |
" |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
354 |
xDel := nil. |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
355 |
yDel := nil. |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
356 |
]. |
4aea1cea284e
care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents:
1941
diff
changeset
|
357 |
|
139 | 358 |
destination notNil ifTrue:[ |
8362 | 359 |
"delegating to an app (or anything else)" |
490
1d2ed059a063
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
360 |
destination keyPress:key x:nil y:nil view:aView. |
139 | 361 |
] ifFalse:[ |
400 | 362 |
destinationView notNil ifTrue:[ |
8362 | 363 |
"delegating to another view" |
3682 | 364 |
forwardedEvent := WindowEvent keyPress:key x:xDel y:yDel view:destinationView. |
2126
1f108c76dfdb
moved event dispatching code to view (where it belongs)
Claus Gittinger <cg@exept.de>
parents:
1967
diff
changeset
|
365 |
destinationView |
3094 | 366 |
dispatchEvent:forwardedEvent |
693
ed557e02b378
dont redelegate delegated messages
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
367 |
withFocusOn:nil |
ed557e02b378
dont redelegate delegated messages
Claus Gittinger <cg@exept.de>
parents:
620
diff
changeset
|
368 |
delegate:false |
400 | 369 |
] |
139 | 370 |
] |
400 | 371 |
|
2126
1f108c76dfdb
moved event dispatching code to view (where it belongs)
Claus Gittinger <cg@exept.de>
parents:
1967
diff
changeset
|
372 |
"Modified: / 20.5.1998 / 22:54:05 / cg" |
128 | 373 |
! |
374 |
||
375 |
keyRelease:key x:x y:y view:aView |
|
139 | 376 |
"handle a delegated event - this is sent by the sensor to actually |
377 |
forward the event (i.e. after I returned true on handlesKeyRelease:. |
|
378 |
Take care of cyclic delegation (via a kludge-test for negative coordinate)." |
|
379 |
||
8362 | 380 |
|forwardedEvent xDel yDel| |
3094 | 381 |
|
8362 | 382 |
(x isNil or:[x < 0]) ifTrue:[ |
400 | 383 |
" |
384 |
already delegated ... ignore |
|
385 |
" |
|
386 |
^ self |
|
387 |
]. |
|
388 |
||
389 |
filter notNil ifTrue:[ |
|
390 |
(filter value:key) ifFalse:[^ self]. |
|
128 | 391 |
]. |
392 |
||
8362 | 393 |
xDel := x. |
394 |
yDel := y. |
|
395 |
||
396 |
x == 0 ifTrue:[ |
|
397 |
" |
|
398 |
already delegated ... care to not delegate twice |
|
399 |
" |
|
400 |
xDel := nil. |
|
401 |
yDel := nil. |
|
402 |
]. |
|
139 | 403 |
destination notNil ifTrue:[ |
8362 | 404 |
"delegating to an app (or anything else)" |
400 | 405 |
destination keyRelease:key x:-1 y:-1 view:aView |
139 | 406 |
] ifFalse:[ |
400 | 407 |
destinationView notNil ifTrue:[ |
8362 | 408 |
"delegating to another view" |
3682 | 409 |
forwardedEvent := WindowEvent keyRelease:key x:-1 y:-1 view:destinationView. |
410 |
destinationView dispatchEvent:forwardedEvent withFocusOn:nil delegate:false |
|
400 | 411 |
] |
139 | 412 |
] |
400 | 413 |
|
2126
1f108c76dfdb
moved event dispatching code to view (where it belongs)
Claus Gittinger <cg@exept.de>
parents:
1967
diff
changeset
|
414 |
"Modified: / 20.5.1998 / 22:54:32 / cg" |
128 | 415 |
! ! |
244 | 416 |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
417 |
!KeyboardForwarder methodsFor:'focus forwarding'! |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
418 |
|
2506 | 419 |
hasKeyboardFocus:aBoolean |
420 |
"forward focus information to my destination" |
|
421 |
||
422 |
destinationView notNil ifTrue:[ |
|
423 |
destinationView hasKeyboardFocus:aBoolean |
|
424 |
]. |
|
425 |
||
426 |
"Modified: 25.2.1997 / 23:16:35 / cg" |
|
427 |
! |
|
428 |
||
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
429 |
showFocus:explicit |
1380 | 430 |
"forward focus information to my destination" |
431 |
||
432 |
|d| |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
433 |
|
1380 | 434 |
destinationView notNil ifTrue:[ |
435 |
d := destinationView |
|
436 |
] ifFalse:[ |
|
437 |
d := destination |
|
438 |
]. |
|
439 |
d notNil ifTrue:[ |
|
440 |
d showFocus:explicit |
|
441 |
] |
|
442 |
||
443 |
"Modified: 25.2.1997 / 23:16:35 / cg" |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
444 |
! |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
445 |
|
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
446 |
showNoFocus:explicit |
1380 | 447 |
"forward focus information to my destination" |
448 |
||
449 |
|d| |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
450 |
|
1380 | 451 |
destinationView notNil ifTrue:[ |
452 |
d := destinationView |
|
453 |
] ifFalse:[ |
|
454 |
d := destination |
|
455 |
]. |
|
456 |
d notNil ifTrue:[ |
|
457 |
d showNoFocus:explicit |
|
458 |
] |
|
459 |
||
460 |
"Modified: 25.2.1997 / 23:16:40 / cg" |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
461 |
! ! |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
462 |
|
244 | 463 |
!KeyboardForwarder methodsFor:'queries'! |
464 |
||
8362 | 465 |
checkCondition:typeOfEvent key:key view:aView |
466 |
"return true, if I am interested in an event with type |
|
467 |
(#keyPress or #keyRelease) and key for aView." |
|
1941 | 468 |
|
1693 | 469 |
|wg| |
470 |
||
400 | 471 |
filter notNil ifTrue:[ |
472 |
(filter value:key) ifFalse:[^ false]. |
|
473 |
]. |
|
474 |
||
244 | 475 |
condition notNil ifTrue:[ |
400 | 476 |
condition == #noFocus ifTrue:[ |
1941 | 477 |
wg := aView windowGroup. |
478 |
(wg isNil or:[wg focusView notNil]) ifTrue:[^ false] |
|
400 | 479 |
]. |
480 |
condition isBlock ifTrue:[ |
|
8362 | 481 |
(condition value:typeOfEvent value:key value:aView) ifFalse:[^ false] |
400 | 482 |
] |
244 | 483 |
]. |
484 |
sourceView notNil ifTrue:[ |
|
400 | 485 |
^ aView == sourceView |
244 | 486 |
]. |
487 |
^ true |
|
400 | 488 |
|
1941 | 489 |
"Modified: / 31.10.1997 / 20:24:42 / cg" |
244 | 490 |
! |
491 |
||
492 |
delegatesTo:someone |
|
493 |
"return true, if I delegate events to someone" |
|
494 |
||
495 |
^ destination == someone or:[destinationView == someone] |
|
496 |
! |
|
497 |
||
6352 | 498 |
handlesButtonMotion:something inView:aView |
499 |
"I am not interested in button events" |
|
500 |
||
501 |
^ false |
|
502 |
! |
|
503 |
||
504 |
handlesButtonPress:something inView:aView |
|
505 |
"I am not interested in button events" |
|
506 |
||
507 |
^ false |
|
508 |
! |
|
509 |
||
244 | 510 |
handlesKeyPress:key inView:aView |
511 |
"this is the query from the sensor to ask me if I would like to |
|
512 |
get a keyPress event for key from aView. Return true, if I want so, |
|
513 |
false otherwise." |
|
514 |
||
515 |
^ self checkCondition:#keyPress key:key view:aView |
|
516 |
! |
|
517 |
||
518 |
handlesKeyRelease:key inView:aView |
|
519 |
"this is the query from the sensor to ask me if I would like to |
|
520 |
get a keyRelease event for key from aView. Return true, if I want so, |
|
521 |
false otherwise." |
|
522 |
||
523 |
^ self checkCondition:#keyRelease key:key view:aView |
|
6352 | 524 |
! |
525 |
||
526 |
handlesPointerEnter:something inView:aView |
|
527 |
"I am not interested in pointer events" |
|
528 |
||
529 |
^ false |
|
530 |
! |
|
531 |
||
532 |
handlesPointerLeave:something inView:aView |
|
533 |
"I am not interested in pointer events" |
|
534 |
||
535 |
^ false |
|
244 | 536 |
! ! |
537 |
||
251 | 538 |
!KeyboardForwarder class methodsFor:'documentation'! |
539 |
||
540 |
version |
|
7660 | 541 |
^ '$Header$' |
251 | 542 |
! ! |
6352 | 543 |