author | fm |
Thu, 16 Oct 2008 14:08:17 +0200 | |
changeset 2548 | 07251b4e7ac9 |
parent 2516 | d088b12a7948 |
child 2617 | 91adf98676da |
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 |
|
2476
7fa9e8576594
changed #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2390
diff
changeset
|
66 |
buttonMotion:buttonAndModifierState 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 |
||
2516 | 98 |
focusInView:aView |
99 |
"not handled here - should be redefined in a concrete subclass" |
|
100 |
||
101 |
^ false |
|
102 |
! |
|
103 |
||
104 |
focusOutView:aView |
|
105 |
"not handled here - should be redefined in a concrete subclass" |
|
106 |
||
107 |
^ false |
|
108 |
! |
|
109 |
||
1424 | 110 |
hasKeyboardFocus:aBoolean view:aView |
111 |
"not handled here - should be redefined in a concrete subclass" |
|
112 |
||
113 |
^ false |
|
114 |
! |
|
115 |
||
123 | 116 |
keyPress:key x:x y:y view:aView |
574 | 117 |
"not handled here - should be redefined in a concrete subclass" |
213 | 118 |
|
123 | 119 |
^ false |
120 |
||
213 | 121 |
"Modified: 23.4.1996 / 21:58:08 / cg" |
123 | 122 |
! |
123 |
||
124 |
keyRelease:key x:x y:y view:aView |
|
574 | 125 |
"not handled here - should be redefined in a concrete subclass" |
213 | 126 |
|
60 | 127 |
^ false |
128 |
||
213 | 129 |
"Modified: 23.4.1996 / 21:58:11 / cg" |
60 | 130 |
! |
131 |
||
1178
44f1fee1b444
pass x/y with mouseWheel event
Claus Gittinger <cg@exept.de>
parents:
1176
diff
changeset
|
132 |
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView |
1173 | 133 |
"not handled here - can be redefined in a concrete subclass" |
134 |
||
135 |
^ false |
|
136 |
||
137 |
"Modified: / 23.4.1996 / 21:57:54 / cg" |
|
138 |
"Created: / 21.5.1999 / 13:07:13 / cg" |
|
139 |
! |
|
140 |
||
60 | 141 |
pointerEnter:state x:x y:y view:view |
574 | 142 |
"not handled here - should be redefined in a concrete subclass" |
213 | 143 |
|
60 | 144 |
^ false |
145 |
||
213 | 146 |
"Modified: 23.4.1996 / 21:58:14 / cg" |
60 | 147 |
! |
148 |
||
123 | 149 |
pointerLeave:state view:view |
574 | 150 |
"not handled here - should be redefined in a concrete subclass" |
213 | 151 |
|
60 | 152 |
^ false |
153 |
||
213 | 154 |
"Modified: 23.4.1996 / 21:58:17 / cg" |
2390 | 155 |
! ! |
156 |
||
157 |
!EventListener methodsFor:'events-window creation'! |
|
1262 | 158 |
|
159 |
postCreateView:aView |
|
160 |
^ self |
|
161 |
! |
|
162 |
||
163 |
preCreateView:aView |
|
164 |
^ self |
|
2390 | 165 |
! |
574 | 166 |
|
167 |
preCreateView:aView origin:org |
|
168 |
"invoked right before a view is about to be physically created. |
|
169 |
May return a new origin." |
|
170 |
||
171 |
^ org |
|
172 |
! ! |
|
173 |
||
60 | 174 |
!EventListener methodsFor:'listen'! |
175 |
||
176 |
listen |
|
177 |
"install myself as listener" |
|
178 |
||
1262 | 179 |
WindowSensor addEventListener:self |
60 | 180 |
|
181 |
" |
|
182 |
|listener| |
|
183 |
||
184 |
listener := EventListener new. |
|
185 |
listener listen. |
|
186 |
(Delay forSeconds:20) wait. |
|
187 |
listener unlisten |
|
188 |
" |
|
189 |
! |
|
190 |
||
1262 | 191 |
processEvent:ev |
1271 | 192 |
"process an event; if true is returned, the event is considered to be |
193 |
'eaten' by the listener, and not passed to the view. |
|
194 |
If false is returned, the event is processed as usual. |
|
195 |
Here, the event is dispatched into one of the button*/key* etc. methods" |
|
196 |
||
1424 | 197 |
Error handle:[:ex | |
1939 | 198 |
('Listener [info]: error while processing event: ' , ex description) infoPrintCR. |
1424 | 199 |
^ false |
200 |
] do:[ |
|
201 |
^ ev dispatchWithViewArgumentTo:self |
|
202 |
] |
|
1262 | 203 |
! |
204 |
||
60 | 205 |
unlisten |
206 |
"uninstall myself as listener" |
|
207 |
||
1262 | 208 |
WindowSensor removeEventListener:self |
60 | 209 |
! ! |
123 | 210 |
|
1173 | 211 |
!EventListener class methodsFor:'documentation'! |
127 | 212 |
|
213 |
version |
|
2516 | 214 |
^ '$Header: /cvs/stx/stx/libview2/EventListener.st,v 1.25 2008-07-09 12:20:38 fm Exp $' |
127 | 215 |
! ! |