184 to destination (Independent of the view in which the event originally |
184 to destination (Independent of the view in which the event originally |
185 occurred). The forwarded event will be reported including |
185 occurred). The forwarded event will be reported including |
186 the original view as argument (i.e. as #keyPress:x:y:view:). |
186 the original view as argument (i.e. as #keyPress:x:y:view:). |
187 Use this, if the destination is not a view." |
187 Use this, if the destination is not a view." |
188 |
188 |
189 ^ self new destination:destination |
189 ^ self to:destination condition:nil filter:nil |
190 ! |
190 ! |
191 |
191 |
192 to:destination condition:aCondition |
192 to:destination condition:aCondition |
193 "create and return a new KeyboardForwarder to redirect any key event |
193 "create and return a new KeyboardForwarder to redirect any key event |
194 to destinationView (Independent of the view in which the event originally |
194 to destinationView (Independent of the view in which the event originally |
195 occurred) but only, if some condition as specified by aCondition |
195 occurred) but only, if some condition as specified by aCondition |
196 is met. The forwarded event will be reported including |
196 is met. The forwarded event will be reported including |
197 the original view as argument (i.e. as #keyPress:x:y:view:). |
197 the original view as argument (i.e. as #keyPress:x:y:view:). |
198 Use this, if the destination is not a view." |
198 Use this, if the destination is not a view." |
199 |
199 |
200 ^ self new destination:destination; condition:aCondition |
200 ^ self to:destination condition:aCondition filter:nil |
|
201 ! |
|
202 |
|
203 to:destination condition:aCondition filter:aFilterBlock |
|
204 "create and return a new KeyboardForwarder to redirect any key event |
|
205 to destinationView (Independent of the view in which the event originally |
|
206 occurred) but only, if some condition as specified by aCondition |
|
207 is met and aFilterBlock returns true for that key. |
|
208 The forwarded event will be reported including |
|
209 the original view as argument (i.e. as #keyPress:x:y:view:). |
|
210 Use this, if the destination is not a view." |
|
211 |
|
212 ^ self new destination:destination; condition:aCondition; filter:aFilterBlock |
201 ! |
213 ! |
202 |
214 |
203 toView:destinationView |
215 toView:destinationView |
204 "create and return a new KeyboardForwarder to redirect any key event |
216 "create and return a new KeyboardForwarder to redirect any key event |
205 to destinationView (Independent of the view in which the event originally |
217 to destinationView (Independent of the view in which the event originally |
206 occurred). The forwarded event will be reported excluding |
218 occurred). The forwarded event will be reported excluding |
207 the original view as argument (i.e. as #keyPress:x:y:). |
219 the original view as argument (i.e. as #keyPress:x:y:). |
208 Use this, if the destination is a view." |
220 Use this, if the destination is a view." |
209 |
221 |
210 ^ self new destinationView:destinationView |
222 ^ self toView:destinationView condition:nil filter:nil |
211 ! |
223 ! |
212 |
224 |
213 toView:destinationView condition:aCondition |
225 toView:destinationView condition:aCondition |
214 "create and return a new KeyboardForwarder to redirect any key event |
226 "create and return a new KeyboardForwarder to redirect any key event |
215 to destinationView (Independent of the view in which the event originally |
227 to destinationView (Independent of the view in which the event originally |
216 occurred) but only, if some condition as specified by aCondition |
228 occurred) but only, if some condition as specified by aCondition |
217 is met. The forwarded event will be reported excluding |
229 is met. The forwarded event will be reported excluding |
218 the original view as argument (i.e. as #keyPress:x:y:). |
230 the original view as argument (i.e. as #keyPress:x:y:). |
219 Use this, if the destination is a view." |
231 Use this, if the destination is a view." |
220 |
232 |
221 ^ self new destinationView:destinationView; condition:aCondition |
233 ^ self toView:destinationView condition:aCondition filter:nil |
|
234 ! |
|
235 |
|
236 toView:destinationView condition:aCondition filter:aFilterBlock |
|
237 "create and return a new KeyboardForwarder to redirect any key event |
|
238 to destinationView (Independent of the view in which the event originally |
|
239 occurred) but only, if some condition as specified by aCondition |
|
240 is met and aFilterBlock returns true for that key. |
|
241 The forwarded event will be reported excluding |
|
242 the original view as argument (i.e. as #keyPress:x:y:). |
|
243 Use this, if the destination is a view." |
|
244 |
|
245 ^ self new destinationView:destinationView; condition:aCondition; filter:aFilterBlock |
222 ! ! |
246 ! ! |
223 |
247 |
224 !KeyboardForwarder methodsFor:'accessing'! |
248 !KeyboardForwarder methodsFor:'accessing'! |
225 |
249 |
226 condition:aCondition |
250 condition:aCondition |
272 "handle a delegated event - this is sent by the sensor to actually |
304 "handle a delegated event - this is sent by the sensor to actually |
273 forward the event (i.e. after I returned true on handlesKeyPress:. |
305 forward the event (i.e. after I returned true on handlesKeyPress:. |
274 Take care of cyclic delegation (via a kludge-test for negative coordinate)." |
306 Take care of cyclic delegation (via a kludge-test for negative coordinate)." |
275 |
307 |
276 x < 0 ifTrue:[ |
308 x < 0 ifTrue:[ |
277 " |
309 " |
278 already delegated ... ignore |
310 already delegated ... ignore |
279 " |
311 " |
280 ^ self |
312 ^ self |
|
313 ]. |
|
314 |
|
315 filter notNil ifTrue:[ |
|
316 (filter value:key) ifFalse:[^ self]. |
281 ]. |
317 ]. |
282 |
318 |
283 destination notNil ifTrue:[ |
319 destination notNil ifTrue:[ |
284 destination keyPress:key x:-1 y:-1 view:aView. |
320 destination keyPress:key x:-1 y:-1 view:aView. |
285 ] ifFalse:[ |
321 ] ifFalse:[ |
286 destinationView notNil ifTrue:[ |
322 destinationView notNil ifTrue:[ |
287 WindowEvent |
323 WindowEvent |
288 sendEvent:#keyPress:x:y: |
324 sendEvent:#keyPress:x:y: |
289 arguments:(Array with:key with:-1 with:-1) |
325 arguments:(Array with:key with:-1 with:-1) |
290 view:destinationView |
326 view:destinationView |
291 ] |
327 ] |
292 ] |
328 ] |
|
329 |
|
330 "Modified: 4.2.1996 / 20:35:52 / cg" |
293 ! |
331 ! |
294 |
332 |
295 keyRelease:key x:x y:y view:aView |
333 keyRelease:key x:x y:y view:aView |
296 "handle a delegated event - this is sent by the sensor to actually |
334 "handle a delegated event - this is sent by the sensor to actually |
297 forward the event (i.e. after I returned true on handlesKeyRelease:. |
335 forward the event (i.e. after I returned true on handlesKeyRelease:. |
298 Take care of cyclic delegation (via a kludge-test for negative coordinate)." |
336 Take care of cyclic delegation (via a kludge-test for negative coordinate)." |
299 |
337 |
300 x < 0 ifTrue:[ |
338 x < 0 ifTrue:[ |
301 " |
339 " |
302 already delegated ... ignore |
340 already delegated ... ignore |
303 " |
341 " |
304 ^ self |
342 ^ self |
|
343 ]. |
|
344 |
|
345 filter notNil ifTrue:[ |
|
346 (filter value:key) ifFalse:[^ self]. |
305 ]. |
347 ]. |
306 |
348 |
307 destination notNil ifTrue:[ |
349 destination notNil ifTrue:[ |
308 destination keyRelease:key x:-1 y:-1 view:aView |
350 destination keyRelease:key x:-1 y:-1 view:aView |
309 ] ifFalse:[ |
351 ] ifFalse:[ |
310 destinationView notNil ifTrue:[ |
352 destinationView notNil ifTrue:[ |
311 WindowEvent |
353 WindowEvent |
312 sendEvent:#keyRelease:x:y: |
354 sendEvent:#keyRelease:x:y: |
313 arguments:(Array with:key with:-1 with:-1) |
355 arguments:(Array with:key with:-1 with:-1) |
314 view:destinationView |
356 view:destinationView |
315 ] |
357 ] |
316 ] |
358 ] |
|
359 |
|
360 "Modified: 4.2.1996 / 20:35:55 / cg" |
317 ! ! |
361 ! ! |
318 |
362 |
319 !KeyboardForwarder methodsFor:'focus forwarding'! |
363 !KeyboardForwarder methodsFor:'focus forwarding'! |
320 |
364 |
321 showFocus:explicit |
365 showFocus:explicit |
331 ! ! |
375 ! ! |
332 |
376 |
333 !KeyboardForwarder methodsFor:'queries'! |
377 !KeyboardForwarder methodsFor:'queries'! |
334 |
378 |
335 checkCondition:type key:key view:aView |
379 checkCondition:type key:key view:aView |
|
380 filter notNil ifTrue:[ |
|
381 (filter value:key) ifFalse:[^ false]. |
|
382 ]. |
|
383 |
336 condition notNil ifTrue:[ |
384 condition notNil ifTrue:[ |
337 condition == #noFocus ifTrue:[ |
385 condition == #noFocus ifTrue:[ |
338 aView windowGroup focusView notNil ifTrue:[^ false] |
386 aView windowGroup focusView notNil ifTrue:[^ false] |
339 ]. |
387 ]. |
340 condition isBlock ifTrue:[ |
388 condition isBlock ifTrue:[ |
341 (condition value:type value:key value:aView) ifFalse:[^ false] |
389 (condition value:type value:key value:aView) ifFalse:[^ false] |
342 ] |
390 ] |
343 ]. |
391 ]. |
344 sourceView notNil ifTrue:[ |
392 sourceView notNil ifTrue:[ |
345 ^ aView == sourceView |
393 ^ aView == sourceView |
346 ]. |
394 ]. |
347 ^ true |
395 ^ true |
|
396 |
|
397 "Modified: 4.2.1996 / 20:36:16 / cg" |
348 ! |
398 ! |
349 |
399 |
350 delegatesTo:someone |
400 delegatesTo:someone |
351 "return true, if I delegate events to someone" |
401 "return true, if I delegate events to someone" |
352 |
402 |