author | Claus Gittinger <cg@exept.de> |
Wed, 05 Mar 1997 14:00:58 +0100 | |
changeset 1420 | 960068850f29 |
parent 1330 | fa27e219a425 |
child 1421 | 0f7c6d4ba280 |
permissions | -rw-r--r-- |
26 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 3 |
All Rights Reserved |
26 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
11 | 12 |
|
13 |
Object subclass:#WindowEvent |
|
356 | 14 |
instanceVariableNames:'view type arguments' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-Support' |
|
11 | 18 |
! |
19 |
||
46 | 20 |
!WindowEvent class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 25 |
All Rights Reserved |
46 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
Instances of WindowEvent are created for every event coming from |
|
144 | 39 |
the graphics device. |
40 |
Usually, they are enqueued by the event dispatcher process into |
|
41 |
a sensors input queue, and dequeued & processed by a windowGroup process |
|
42 |
in its event loop. |
|
43 |
||
44 |
WindowEvents hold the event type and additional information (such as key, |
|
45 |
x/y coordinates etc). Also, windowEvents know how to send themself to some |
|
46 |
destination. To provide a common (single) place where event dispatching is |
|
47 |
implemented, this forwarding is done by a clas method here (i.e. not by the |
|
48 |
window group itself). |
|
49 |
||
50 |
The algorithm for event dispatching is: |
|
51 |
||
598 | 52 |
- if the destination view has a keyboard focus set, |
53 |
AND the event is a keyboard event, |
|
54 |
THEN recursively invoke the event dispatching method, |
|
55 |
sending the event to the focus view (or its delegate, as below) |
|
144 | 56 |
|
598 | 57 |
- if the destination view has a delegate, |
58 |
AND its a keyboard, button or pointer event, |
|
59 |
AND the delegate is interested in that event |
|
60 |
(i.e. implements & responds to #handlesXXX with true) |
|
61 |
THEN send the event to the delegate, passing the original view |
|
62 |
as additional argument |
|
144 | 63 |
|
598 | 64 |
- if the view has a nonNil controller, |
65 |
AND its a key, button or pointer event, |
|
66 |
THEN send the event to the controller |
|
144 | 67 |
|
598 | 68 |
- otherwise send the event to the view |
144 | 69 |
|
70 |
||
71 |
If the view has a non-nil transformation, the event is sent as a |
|
72 |
#deviceXXX message, passing device coordinates. Typically, subclasses |
|
73 |
of view do not redefine this method and the inherited default method |
|
74 |
translates these device coordinates into logical coordinates and resends |
|
75 |
an XXX message. |
|
76 |
If the view has no transformation, the XXX message is directly sent here. |
|
77 |
||
78 |
For example, a 'buttonPress:button x:x y:y' event leads to sending of |
|
79 |
'aView deviceButtonPress:button x:x y:y' which resends |
|
80 |
'aView buttonPress:button x:(x-logical) y:(y-logical)' |
|
81 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
82 |
This allows views which are interested in deviceCoordinates to get them |
144 | 83 |
(by redefining #deviceXXX) and other views to transparently get & use |
84 |
logical coordinates. |
|
85 |
||
86 |
Therefore, for a delegated keyPress messages, the flow is: |
|
87 |
||
598 | 88 |
sendEvent |
89 |
view has delegate |
|
90 |
------> ask delegate via 'handlesKeyPress:key inView:view' |
|
91 |
<------ returns true |
|
92 |
------> 'delegate keyPress:key x:x y:y view:view' |
|
93 |
-----> delegate does whatever it wants to do |
|
94 |
(typically sends the event to some other view) |
|
144 | 95 |
|
96 |
for an undelegated message: |
|
97 |
||
598 | 98 |
sendEvent |
99 |
view has delegate |
|
100 |
------> ask delegate via 'handlesKeyPress:key inView:view' |
|
101 |
<------ returns false |
|
102 |
view has controller |
|
103 |
------> 'controller keyPress:key x:x y:y' |
|
104 |
view has no controller |
|
105 |
view has transformation |
|
106 |
----> 'view deviceKeyPress:key x:x y:y' |
|
107 |
inverse transform x/y |
|
108 |
----> 'self keyPress:key x:xLogical y:yLogical' |
|
109 |
view has no transformation |
|
110 |
----> 'view keyPress:key x:x y:y' |
|
111 |
||
612 | 112 |
[author:] |
113 |
Claus Gittinger |
|
114 |
||
598 | 115 |
[see also:] |
116 |
WindowGroup WindowSensor |
|
117 |
DeviceWorkstation View |
|
118 |
KeyboardMap KeyboardForwarder EventListener |
|
119 |
||
46 | 120 |
" |
121 |
! ! |
|
122 |
||
11 | 123 |
!WindowEvent class methodsFor:'instance creation'! |
124 |
||
244 | 125 |
damageFor:aView rectangle:aRectangle |
126 |
"create and return a new damage Event for aRectangle |
|
127 |
in aView" |
|
11 | 128 |
|
244 | 129 |
^ (self new) for:aView type:#damage arguments:aRectangle |
130 |
||
46 | 131 |
! |
132 |
||
72 | 133 |
for:aView type:aSymbol |
134 |
"create and return a new windowEvent for sending |
|
135 |
aSymbol-message with no arguments to aView" |
|
136 |
||
137 |
^ (self new) for:aView type:aSymbol arguments:#() |
|
138 |
! |
|
139 |
||
244 | 140 |
for:aView type:aSymbol arguments:argArray |
141 |
"create and return a new windowEvent for sending |
|
142 |
aSymbol-message with arguments to aView" |
|
28 | 143 |
|
244 | 144 |
^ (self new) for:aView type:aSymbol arguments:argArray |
28 | 145 |
! ! |
146 |
||
115 | 147 |
!WindowEvent class methodsFor:'forwarding events'! |
148 |
||
149 |
sendEvent:type arguments:arguments view:view |
|
150 |
"forward the event represented by type and arguments to the views delegate, |
|
151 |
the views controller or the view. |
|
11 | 152 |
|
115 | 153 |
If there is a delegate, only messages which are understood by it are |
154 |
forwarded. Also, the delegate is asked if it is willing to handle the event |
|
155 |
before. |
|
156 |
Delegated messages get the original view as an extra argument. |
|
157 |
Delegation has higher priority than controller forwarding." |
|
11 | 158 |
|
135 | 159 |
^ self |
160 |
sendEvent:type |
|
161 |
arguments:arguments |
|
162 |
view:view |
|
163 |
withFocusOn:nil |
|
164 |
delegate:true |
|
89 | 165 |
! |
166 |
||
115 | 167 |
sendEvent:type arguments:argArray view:view withFocusOn:focusView |
168 |
"forward the event represented by type and arguments to the views delegate, |
|
169 |
the views controller or the view. |
|
170 |
If focusView is nonNil, and it is a keyboard event, it is forwarded to this |
|
141 | 171 |
view (even if there is a delegate). |
115 | 172 |
|
89 | 173 |
If there is a delegate, only messages which are understood by it are |
115 | 174 |
forwarded. Also, the delegate is asked if it is willing to handle the event |
175 |
before. |
|
176 |
Delegated messages get the original view as an extra argument. |
|
89 | 177 |
Delegation has higher priority than both controller or focusView |
178 |
forwarding." |
|
179 |
||
135 | 180 |
^ self |
181 |
sendEvent:type |
|
182 |
arguments:argArray |
|
183 |
view:view |
|
184 |
withFocusOn:focusView |
|
185 |
delegate:true |
|
186 |
! |
|
187 |
||
188 |
sendEvent:type arguments:argArray view:view withFocusOn:focusView delegate:doDelegate |
|
189 |
"forward the event represented by type and arguments to the views delegate, |
|
190 |
the views controller or the view. |
|
191 |
If focusView is nonNil, and it is a keyboard event, it is forwarded to this |
|
192 |
view (but not if there was a delegate in the first place). |
|
193 |
||
194 |
If doDelegate is true, keyboard and button events are forwarded to a |
|
195 |
delegate object (if non-nil). DoDelegate may be passed as true, to |
|
196 |
handle events which are already delegated. |
|
197 |
If there is a delegate, only messages which are understood by it are |
|
198 |
forwarded. Also, the delegate is asked if it is willing to handle the event |
|
199 |
before. |
|
200 |
Delegated messages get the original view as an extra argument. |
|
201 |
Delegation has higher priority than both controller or focusView |
|
202 |
forwarding." |
|
203 |
||
115 | 204 |
|delegate selector delegateMessage delegateQuery |
205 |
eventReceiver controller deviceMessage |
|
206 |
isKeyEvent isButtonEvent isPointerEvent trans| |
|
207 |
||
208 |
isKeyEvent := isButtonEvent := isPointerEvent := false. |
|
11 | 209 |
|
115 | 210 |
(type == #'keyPress:x:y:') ifTrue:[ |
1420 | 211 |
isKeyEvent := true. |
212 |
deviceMessage := #'deviceKeyPress:x:y:'. |
|
213 |
delegateMessage := #'keyPress:x:y:view:'. |
|
214 |
delegateQuery := #'handlesKeyPress:inView:'. |
|
115 | 215 |
] ifFalse:[ (type == #'keyRelease:x:y:') ifTrue:[ |
1420 | 216 |
isKeyEvent := true. |
217 |
deviceMessage := #'deviceKeyRelease:x:y:'. |
|
218 |
delegateMessage := #'keyRelease:x:y:view:'. |
|
219 |
delegateQuery := #'handlesKeyRelease:inView:'. |
|
141 | 220 |
] ifFalse:[ (type == #'buttonMotion:x:y:') ifTrue:[ |
1420 | 221 |
isButtonEvent := true. |
222 |
deviceMessage := #'deviceButtonMotion:x:y:'. |
|
223 |
delegateMessage := #'buttonMotion:x:y:view:'. |
|
224 |
delegateQuery := #'handlesButtonMotion:inView:'. |
|
115 | 225 |
] ifFalse:[ (type == #'buttonPress:x:y:') ifTrue:[ |
1420 | 226 |
isButtonEvent := true. |
227 |
deviceMessage := #'deviceButtonPress:x:y:'. |
|
228 |
delegateMessage := #'buttonPress:x:y:view:'. |
|
229 |
delegateQuery := #'handlesButtonPress:inView:'. |
|
115 | 230 |
] ifFalse:[ (type == #'buttonRelease:x:y:') ifTrue:[ |
1420 | 231 |
isButtonEvent := true. |
232 |
deviceMessage := #'deviceButtonRelease:x:y:'. |
|
233 |
delegateMessage := #'buttonRelease:x:y:view:'. |
|
234 |
delegateQuery := #'handlesButtonRelease:inView:'. |
|
115 | 235 |
] ifFalse:[ (type == #'buttonShiftPress:x:y:') ifTrue:[ |
1420 | 236 |
isButtonEvent := true. |
237 |
deviceMessage := #'deviceButtonShiftPress:x:y:'. |
|
238 |
delegateMessage := #'buttonShiftPress:x:y:view:'. |
|
239 |
delegateQuery := #'handlesButtonShiftPress:inView:'. |
|
115 | 240 |
] ifFalse:[ (type == #'buttonMultiPress:x:y:') ifTrue:[ |
1420 | 241 |
isButtonEvent := true. |
242 |
deviceMessage := #'deviceButtonMultiPress:x:y:'. |
|
243 |
delegateMessage := #'buttonMultiPress:x:y:view:'. |
|
244 |
delegateQuery := #'handlesButtonMultiPress:inView:'. |
|
115 | 245 |
] ifFalse:[ (type == #'pointerEnter:x:y:') ifTrue:[ |
1420 | 246 |
isPointerEvent := true. |
247 |
deviceMessage := #'devicePointerEnter:x:y:'. |
|
248 |
delegateMessage := #'pointerEnter:x:y:view:'. |
|
249 |
delegateQuery := #'handlesPointerEnter:inView:'. |
|
115 | 250 |
] ifFalse:[ (type == #'pointerLeave:') ifTrue:[ |
1420 | 251 |
isPointerEvent := true. |
252 |
deviceMessage := type. |
|
253 |
delegateMessage := #'pointerLeave:view:'. |
|
254 |
delegateQuery := #'handlesPointerLeave:inView:'. |
|
115 | 255 |
] ifFalse:[ (type == #'exposeX:y:width:height:') ifTrue:[ |
1420 | 256 |
deviceMessage := #'deviceExposeX:y:width:height:'. |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1158
diff
changeset
|
257 |
] ifFalse:[ (type == #'graphicsExposeX:y:width:height:final:') ifTrue:[ |
1420 | 258 |
deviceMessage := #'deviceGraphicsExposeX:y:width:height:final:'. |
115 | 259 |
]]]]]]]]]]]. |
89 | 260 |
|
141 | 261 |
" |
262 |
if there is a focusView, and its a keyboard event, pass it |
|
263 |
to that view (or its controller, or its delegate). |
|
264 |
In this case, a coordinate which is outside of |
|
143 | 265 |
the focusView (0 @ 0) is passed as x/y coordinates. |
141 | 266 |
" |
267 |
(focusView notNil |
|
268 |
and:[isKeyEvent]) ifTrue:[ |
|
1420 | 269 |
self sendEvent:type |
270 |
arguments:(Array with:(argArray at:1) with:0 with:0) |
|
271 |
view:focusView |
|
272 |
withFocusOn:nil |
|
273 |
delegate:doDelegate. |
|
274 |
^ self |
|
141 | 275 |
]. |
276 |
||
135 | 277 |
doDelegate ifTrue:[ |
1420 | 278 |
" |
279 |
handle delegated messages |
|
280 |
" |
|
281 |
(isKeyEvent |
|
282 |
or:[isButtonEvent |
|
283 |
or:[isPointerEvent]]) ifTrue:[ |
|
284 |
delegate := view delegate. |
|
135 | 285 |
|
1420 | 286 |
" |
287 |
what a kludge - sending to delegate requires |
|
288 |
another selector and an additional argument ... |
|
289 |
" |
|
290 |
(delegate notNil |
|
291 |
and:[delegate respondsTo:delegateMessage]) ifTrue:[ |
|
292 |
" |
|
293 |
is the delegate interested in that event ? |
|
294 |
(if it does not respond to the handlesXXX message, |
|
295 |
we assume: NO) |
|
296 |
" |
|
297 |
((delegate respondsTo:delegateQuery) |
|
298 |
and:[delegate perform:delegateQuery with:(argArray at:1) with:view]) ifTrue:[ |
|
299 |
" |
|
300 |
mhmh ... have to convert to logical coordinates |
|
301 |
" |
|
302 |
(trans := view transformation) notNil ifTrue:[ |
|
303 |
argArray size > 2 ifTrue:[ |
|
304 |
argArray at:2 put:(trans applyInverseToX:(argArray at:2)). |
|
305 |
argArray at:3 put:(trans applyInverseToY:(argArray at:3)). |
|
306 |
]. |
|
307 |
]. |
|
308 |
((delegateMessage startsWith:'key') |
|
309 |
or:[(delegateMessage startsWith:'deviceKey')]) ifTrue:[ |
|
310 |
'delegate: ' print. |
|
311 |
delegate printCR. |
|
312 |
delegateMessage printCR. |
|
313 |
argArray printCR. |
|
314 |
]. |
|
315 |
argArray isNil ifTrue:[ |
|
316 |
delegate perform:delegateMessage with:view |
|
317 |
] ifFalse:[ |
|
318 |
delegate perform:delegateMessage withArguments:(argArray copyWith:view) |
|
319 |
]. |
|
320 |
^ self |
|
321 |
] |
|
322 |
]. |
|
323 |
]. |
|
89 | 324 |
]. |
325 |
||
326 |
" |
|
327 |
if there is a controller, that one gets all user events |
|
328 |
" |
|
329 |
eventReceiver := view. |
|
330 |
(controller := view controller) notNil ifTrue:[ |
|
1420 | 331 |
(isKeyEvent |
332 |
or:[isButtonEvent |
|
333 |
or:[isPointerEvent |
|
334 |
or:[(type == #focusIn) |
|
335 |
or:[(type == #focusOut)]]]]) ifTrue:[ |
|
336 |
eventReceiver := controller. |
|
337 |
] |
|
89 | 338 |
]. |
339 |
||
340 |
" |
|
115 | 341 |
finally, another one: |
89 | 342 |
if the view has a transformation, edit the selector |
343 |
from #foo to #deviceFoo... |
|
344 |
This allows the view to handle the event either in device or |
|
345 |
logical coordinates. (since the deviceFoo-messages default implementation |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
346 |
in DisplaySurface translates and resends). |
89 | 347 |
Actually, I could always send deviceXXX without speed penalty |
348 |
(event sending is no high frequency operation), but that just adds |
|
349 |
another context to any debuggers walkback, making things less clear. |
|
350 |
" |
|
115 | 351 |
selector := type. |
352 |
||
89 | 353 |
view transformation notNil ifTrue:[ |
1420 | 354 |
(isKeyEvent |
355 |
or:[isButtonEvent |
|
356 |
or:[isPointerEvent |
|
357 |
or:[(type == #'exposeX:y:width:height:') |
|
358 |
or:[(type == #'graphicsExposeX:y:width:height:final:')]]]]) ifTrue:[ |
|
359 |
selector := deviceMessage |
|
360 |
] |
|
89 | 361 |
]. |
1420 | 362 |
|
363 |
((selector startsWith:'key') |
|
364 |
or:[(selector startsWith:'deviceKey')]) ifTrue:[ |
|
365 |
eventReceiver printCR. |
|
366 |
selector printCR. |
|
367 |
argArray printCR. |
|
368 |
]. |
|
369 |
||
115 | 370 |
eventReceiver perform:selector withArguments:argArray |
1420 | 371 |
|
372 |
"Modified: 5.3.1997 / 12:02:00 / cg" |
|
115 | 373 |
! ! |
374 |
||
244 | 375 |
!WindowEvent methodsFor:'accessing'! |
376 |
||
377 |
arguments |
|
378 |
"return the arguments of the event" |
|
379 |
||
380 |
^ arguments |
|
381 |
! |
|
382 |
||
383 |
arguments:anArray |
|
384 |
"set the arguments" |
|
385 |
||
386 |
arguments := anArray |
|
387 |
! |
|
388 |
||
389 |
key |
|
390 |
"return the key of the key-event. For non key-events, nil is returned." |
|
391 |
||
392 |
((type == #keyPress:x:y:) |
|
393 |
or:[type == #keyRelease:x:y:]) ifTrue:[ |
|
394 |
^ arguments at:1 |
|
395 |
]. |
|
396 |
^ nil |
|
397 |
! |
|
398 |
||
399 |
rectangle |
|
400 |
"return the damage rectangle" |
|
401 |
||
402 |
^ arguments "consider this a kludge" |
|
403 |
! |
|
404 |
||
405 |
type |
|
406 |
"return the type of the event" |
|
407 |
||
408 |
^ type |
|
409 |
! |
|
410 |
||
411 |
view |
|
412 |
"return the view, for which the event is for" |
|
413 |
||
414 |
^ view |
|
415 |
! |
|
416 |
||
417 |
view:aView |
|
418 |
"set the view, for which the event is for" |
|
419 |
||
420 |
view := aView |
|
421 |
! ! |
|
422 |
||
511
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
423 |
!WindowEvent methodsFor:'printing & storing'! |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
424 |
|
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
425 |
displayString |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
426 |
^ self className |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
427 |
, '(' , type storeString |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
428 |
, ' view: ' , view className |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
429 |
, ' args: ' , arguments displayString |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
430 |
, ')' |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
431 |
|
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
432 |
"Created: 7.3.1996 / 14:55:50 / cg" |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
433 |
"Modified: 7.3.1996 / 14:58:21 / cg" |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
434 |
! ! |
233dabfcc81c
added #displayString (for eventTracing)
Claus Gittinger <cg@exept.de>
parents:
356
diff
changeset
|
435 |
|
244 | 436 |
!WindowEvent methodsFor:'private accessing'! |
437 |
||
438 |
for:aView type:aSymbol arguments:argArray |
|
439 |
"set the instance variables of the event" |
|
440 |
||
441 |
view := aView. |
|
442 |
type := aSymbol. |
|
443 |
arguments := argArray |
|
444 |
! ! |
|
445 |
||
446 |
!WindowEvent methodsFor:'queries'! |
|
447 |
||
448 |
isButtonEvent |
|
449 |
"return true, if this event is a button event" |
|
450 |
||
451 |
^ (type == #buttonPress:x:y:) |
|
452 |
or:[type == #buttonRelease:x:y: |
|
453 |
or:[type == #'buttonShiftPress:x:y:' |
|
454 |
or:[type == #'buttonMultiPress:x:y:' |
|
455 |
or:[type == #'buttonMotion:x:y:']]]] |
|
456 |
! |
|
457 |
||
1420 | 458 |
isButtonPressEvent |
459 |
"return true, if this event is a buttonPress event" |
|
460 |
||
461 |
^ (type == #buttonPress:x:y:) |
|
462 |
||
463 |
"Created: 5.3.1997 / 12:25:43 / cg" |
|
464 |
! |
|
465 |
||
244 | 466 |
isDamage |
467 |
"return true, if this is a damage event" |
|
468 |
||
469 |
^ type == #damage |
|
470 |
! |
|
471 |
||
1420 | 472 |
isFocusEvent |
473 |
"return true, if this event is a focusIn/focusOut event" |
|
474 |
||
475 |
^ (type == #focusIn) or:[type == #focusOut] |
|
476 |
||
477 |
"Created: 5.3.1997 / 12:12:37 / cg" |
|
478 |
! |
|
479 |
||
480 |
isFocusInEvent |
|
481 |
"return true, if this event is a focusIn event" |
|
482 |
||
483 |
^ (type == #focusIn) |
|
484 |
||
485 |
"Created: 5.3.1997 / 12:18:10 / cg" |
|
486 |
! |
|
487 |
||
244 | 488 |
isKeyEvent |
489 |
"return true, if this event is a keyboard event" |
|
490 |
||
491 |
^ (type == #keyPress:x:y:) or:[type == #keyRelease:x:y:] |
|
492 |
! |
|
493 |
||
494 |
isKeyPressEvent |
|
495 |
"return true, if this event is a keyboard event" |
|
496 |
||
497 |
^ (type == #keyPress:x:y:) |
|
356 | 498 |
! |
499 |
||
500 |
isPointerEnterEvent |
|
501 |
"return true, if this event is a pointer-enter event" |
|
502 |
||
503 |
^ (type == #pointerEnter:x:y:) |
|
504 |
||
505 |
"Created: 9.1.1996 / 15:51:24 / cg" |
|
506 |
"Modified: 9.1.1996 / 15:51:40 / cg" |
|
507 |
! |
|
508 |
||
509 |
isPointerEnterLeaveEvent |
|
510 |
"return true, if this event is a pointer-enter/leave event" |
|
511 |
||
512 |
^ (type == #pointerEnter:x:y:) or:[type == #pointerLeave:view:] |
|
513 |
||
514 |
"Created: 9.1.1996 / 15:51:18 / cg" |
|
515 |
! |
|
516 |
||
517 |
isPointerLeaveEvent |
|
518 |
"return true, if this event is a pointer-leave event" |
|
519 |
||
520 |
^ type == #pointerLeave:view: |
|
521 |
||
522 |
"Created: 9.1.1996 / 15:51:36 / cg" |
|
1158 | 523 |
! |
524 |
||
525 |
isUserEvent |
|
526 |
"return true, if this event is a user event (i.e. mouse, keyboard or button)" |
|
527 |
||
528 |
(type == #buttonPress:x:y:) ifTrue:[^ true]. |
|
529 |
(type == #buttonRelease:x:y:) ifTrue:[^ true]. |
|
530 |
(type == #buttonShiftPress:x:y:) ifTrue:[^ true]. |
|
531 |
(type == #buttonMultiPress:x:y:) ifTrue:[^ true]. |
|
532 |
(type == #buttonMotion:x:y:) ifTrue:[^ true]. |
|
533 |
||
534 |
(type == #keyPress:x:y:) ifTrue:[^ true]. |
|
535 |
(type == #keyRelease:x:y:) ifTrue:[^ true]. |
|
536 |
||
1420 | 537 |
(type == #pointerEnter:x:y:) ifTrue:[^ true]. |
538 |
"/ (type == #pointerLeave:) ifTrue:[^ true]. |
|
539 |
||
1158 | 540 |
^ false |
541 |
||
1420 | 542 |
"Modified: 5.3.1997 / 11:27:40 / cg" |
244 | 543 |
! ! |
544 |
||
115 | 545 |
!WindowEvent methodsFor:'sending'! |
546 |
||
547 |
sendEvent |
|
144 | 548 |
"forward the event represented by the receiver to the views delegate, |
549 |
the views controller or the view. Ignore any focusView." |
|
115 | 550 |
|
551 |
self sendEventWithFocusOn:nil |
|
552 |
! |
|
553 |
||
554 |
sendEventWithFocusOn:focusView |
|
144 | 555 |
"forward the event represented by the receiver to the views delegate, |
556 |
the views controller or the view. |
|
557 |
If focusView is nonNil, and the receiver is a keyboard event, |
|
558 |
the event will be forwarded to the focusView instead |
|
559 |
(or its delegate, or its controller)." |
|
115 | 560 |
|
135 | 561 |
self class |
562 |
sendEvent:type |
|
563 |
arguments:arguments |
|
564 |
view:view |
|
565 |
withFocusOn:focusView |
|
566 |
delegate:true |
|
11 | 567 |
! ! |
568 |
||
251 | 569 |
!WindowEvent class methodsFor:'documentation'! |
570 |
||
571 |
version |
|
1420 | 572 |
^ '$Header: /cvs/stx/stx/libview/WindowEvent.st,v 1.32 1997-03-05 13:00:58 cg Exp $' |
251 | 573 |
! ! |