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