author | Claus Gittinger <cg@exept.de> |
Sat, 17 May 2008 12:20:43 +0200 | |
changeset 2454 | e8b9dfacb65b |
parent 2390 | 67d0a61fbadf |
child 2476 | 7fa9e8576594 |
permissions | -rw-r--r-- |
60 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
77 | 3 |
All Rights Reserved |
60 | 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 |
" |
|
1424 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
60 | 14 |
Object subclass:#EventListener |
212 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Support' |
|
60 | 19 |
! |
20 |
||
1173 | 21 |
!EventListener class methodsFor:'documentation'! |
60 | 22 |
|
123 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
||
60 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
98 | 41 |
abstract class for event listeners. EventListeners can be used to intercept |
42 |
incoming events (keyboard & mouse) directly from a sensor, or even |
|
43 |
for a complete display device. |
|
574 | 44 |
A concrete application is the bubble help, which tracks entering/leaving |
45 |
views, and pops up some help message. |
|
46 |
See concrete code in ActiveHelp. |
|
47 |
||
98 | 48 |
For each intercepted event, a corresponding method is called for in instances |
574 | 49 |
of myself - these MUST return true, if the event is to be ignored (i.e. |
50 |
assumed to be processed and consumed by the reader, |
|
51 |
and MUST return false, if the normal event procedure should be performed. |
|
52 |
Since this is an abstract class, |
|
53 |
all of my intercept methods return false. |
|
54 |
They are meant to be redefined in concrete subclasses. |
|
212 | 55 |
|
56 |
[see also:] |
|
574 | 57 |
WindowSensor WindowEvent WindowGroup |
222 | 58 |
|
59 |
[author:] |
|
574 | 60 |
Claus Gittinger |
60 | 61 |
" |
62 |
! ! |
|
63 |
||
2390 | 64 |
!EventListener methodsFor:'event handling'! |
60 | 65 |
|
1483 | 66 |
buttonMotion:buttonState x:x y:y view:aView |
574 | 67 |
"not handled here - should be redefined in a concrete subclass" |
213 | 68 |
|
60 | 69 |
^ false |
213 | 70 |
|
71 |
"Modified: 23.4.1996 / 21:57:54 / cg" |
|
60 | 72 |
! |
73 |
||
74 |
buttonMultiPress:button x:x y:y view:aView |
|
574 | 75 |
"not handled here - should be redefined in a concrete subclass" |
213 | 76 |
|
60 | 77 |
^ false |
78 |
||
213 | 79 |
"Modified: 23.4.1996 / 21:57:58 / cg" |
60 | 80 |
! |
81 |
||
82 |
buttonPress:button x:x y:y view:aView |
|
574 | 83 |
"not handled here - should be redefined in a concrete subclass" |
213 | 84 |
|
60 | 85 |
^ false |
86 |
||
213 | 87 |
"Modified: 23.4.1996 / 21:58:01 / cg" |
60 | 88 |
! |
89 |
||
123 | 90 |
buttonRelease:button x:x y:y view:aView |
574 | 91 |
"not handled here - should be redefined in a concrete subclass" |
213 | 92 |
|
60 | 93 |
^ false |
123 | 94 |
|
213 | 95 |
"Modified: 23.4.1996 / 21:58:03 / cg" |
60 | 96 |
! |
97 |
||
1424 | 98 |
hasKeyboardFocus:aBoolean view:aView |
99 |
"not handled here - should be redefined in a concrete subclass" |
|
100 |
||
101 |
^ false |
|
102 |
! |
|
103 |
||
123 | 104 |
keyPress:key x:x y:y view:aView |
574 | 105 |
"not handled here - should be redefined in a concrete subclass" |
213 | 106 |
|
123 | 107 |
^ false |
108 |
||
213 | 109 |
"Modified: 23.4.1996 / 21:58:08 / cg" |
123 | 110 |
! |
111 |
||
112 |
keyRelease:key x:x y:y view:aView |
|
574 | 113 |
"not handled here - should be redefined in a concrete subclass" |
213 | 114 |
|
60 | 115 |
^ false |
116 |
||
213 | 117 |
"Modified: 23.4.1996 / 21:58:11 / cg" |
60 | 118 |
! |
119 |
||
1178
44f1fee1b444
pass x/y with mouseWheel event
Claus Gittinger <cg@exept.de>
parents:
1176
diff
changeset
|
120 |
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView |
1173 | 121 |
"not handled here - can be redefined in a concrete subclass" |
122 |
||
123 |
^ false |
|
124 |
||
125 |
"Modified: / 23.4.1996 / 21:57:54 / cg" |
|
126 |
"Created: / 21.5.1999 / 13:07:13 / cg" |
|
127 |
! |
|
128 |
||
60 | 129 |
pointerEnter:state x:x y:y view:view |
574 | 130 |
"not handled here - should be redefined in a concrete subclass" |
213 | 131 |
|
60 | 132 |
^ false |
133 |
||
213 | 134 |
"Modified: 23.4.1996 / 21:58:14 / cg" |
60 | 135 |
! |
136 |
||
123 | 137 |
pointerLeave:state view:view |
574 | 138 |
"not handled here - should be redefined in a concrete subclass" |
213 | 139 |
|
60 | 140 |
^ false |
141 |
||
213 | 142 |
"Modified: 23.4.1996 / 21:58:17 / cg" |
2390 | 143 |
! ! |
144 |
||
145 |
!EventListener methodsFor:'events-window creation'! |
|
1262 | 146 |
|
147 |
postCreateView:aView |
|
148 |
^ self |
|
149 |
! |
|
150 |
||
151 |
preCreateView:aView |
|
152 |
^ self |
|
2390 | 153 |
! |
574 | 154 |
|
155 |
preCreateView:aView origin:org |
|
156 |
"invoked right before a view is about to be physically created. |
|
157 |
May return a new origin." |
|
158 |
||
159 |
^ org |
|
160 |
! ! |
|
161 |
||
60 | 162 |
!EventListener methodsFor:'listen'! |
163 |
||
164 |
listen |
|
165 |
"install myself as listener" |
|
166 |
||
1262 | 167 |
WindowSensor addEventListener:self |
60 | 168 |
|
169 |
" |
|
170 |
|listener| |
|
171 |
||
172 |
listener := EventListener new. |
|
173 |
listener listen. |
|
174 |
(Delay forSeconds:20) wait. |
|
175 |
listener unlisten |
|
176 |
" |
|
177 |
! |
|
178 |
||
1262 | 179 |
processEvent:ev |
1271 | 180 |
"process an event; if true is returned, the event is considered to be |
181 |
'eaten' by the listener, and not passed to the view. |
|
182 |
If false is returned, the event is processed as usual. |
|
183 |
Here, the event is dispatched into one of the button*/key* etc. methods" |
|
184 |
||
1424 | 185 |
Error handle:[:ex | |
1939 | 186 |
('Listener [info]: error while processing event: ' , ex description) infoPrintCR. |
1424 | 187 |
^ false |
188 |
] do:[ |
|
189 |
^ ev dispatchWithViewArgumentTo:self |
|
190 |
] |
|
1262 | 191 |
! |
192 |
||
60 | 193 |
unlisten |
194 |
"uninstall myself as listener" |
|
195 |
||
1262 | 196 |
WindowSensor removeEventListener:self |
60 | 197 |
! ! |
123 | 198 |
|
1173 | 199 |
!EventListener class methodsFor:'documentation'! |
127 | 200 |
|
201 |
version |
|
2390 | 202 |
^ '$Header: /cvs/stx/stx/libview2/EventListener.st,v 1.23 2008-02-26 10:22:48 cg Exp $' |
127 | 203 |
! ! |