author | Claus Gittinger <cg@exept.de> |
Sun, 11 Dec 2016 22:13:54 +0100 | |
changeset 6006 | 92827801f6ed |
parent 5880 | c232c67f6e7f |
child 6082 | 8e35a927189c |
child 6509 | 110f6a02e2d5 |
permissions | -rw-r--r-- |
5880 | 1 |
"{ Encoding: utf8 }" |
2 |
||
76 | 3 |
" |
4 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2283 | 14 |
"{ Package: 'stx:libwidg' }" |
15 |
||
5323 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
76 | 18 |
Controller subclass:#ButtonController |
262 | 19 |
instanceVariableNames:'enableChannel pressChannel releaseChannel pressed active entered |
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
20 |
isTriggerOnDown autoRepeat repeatBlock initialDelay repeatDelay |
5880 | 21 |
pressActionBlock releaseActionBlock isToggle isRadio buttonDown |
22 |
doubleClickActionBlock' |
|
262 | 23 |
classVariableNames:'' |
24 |
poolDictionaries:'' |
|
25 |
category:'Interface-Support-Controllers' |
|
76 | 26 |
! |
27 |
||
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
28 |
!ButtonController class methodsFor:'documentation'! |
76 | 29 |
|
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
ButtonControllers are used with buttons and handle all user interaction. |
|
47 |
These are automatically created when a Button is created, therefore no manual |
|
48 |
action is required for creation. |
|
5584 | 49 |
In normal applications, you don't have to care for the controller; |
133 | 50 |
access to the controllers behavior is possible via messages to the button. |
125 | 51 |
(setting actions, controlling autorepeat etc.) |
76 | 52 |
|
972 | 53 |
A ButtonController supports 3 types of notifications: |
54 |
MVC change notification - as usual |
|
55 |
channel notifications - through the pressChannel/releaseChannels |
|
56 |
action callBack - through pressAction / releaseAction blocks. |
|
57 |
||
58 |
Notifications are made in the above order (i.e. an actionBlock sees the model |
|
59 |
already changed, if there is a model). |
|
60 |
||
61 |
Having multiple mechanisms here is both historic and to make the life |
|
5584 | 62 |
of simple applications easier - most buttons don't need a model or notification |
972 | 63 |
channels and simply perform some action. |
64 |
In general: actionBlocks are useful, if there is a single subject which |
|
65 |
needs to be told about the press (i.e. actionButtons); |
|
66 |
models should be used when the button represents some value in some other |
|
67 |
object. |
|
68 |
Channels are much like the MVC approach, however, these are useful if |
|
69 |
press/release/label etc. may come from different objects, and a single |
|
70 |
(synthetic) model does not make sense or is not appropriate. |
|
71 |
||
72 |
Actually, the channels are the most general - and the other mechanism could |
|
73 |
(and will, maybe) based upon them; after all, an actionBlock is a channel, |
|
74 |
whcih sends #value to its block .... |
|
75 |
||
76 |
||
77 |
||
133 | 78 |
See examples in the Button class. |
79 |
||
582 | 80 |
[Instance variables:] |
76 | 81 |
|
133 | 82 |
enableChannel <ValueHolder pressing is allowed (default: true) |
582 | 83 |
on Boolean> |
125 | 84 |
|
76 | 85 |
pressed <Boolean> true if currently pressed (read-only) |
125 | 86 |
|
76 | 87 |
entered <Boolean> true if the cursor is currently in this view |
125 | 88 |
|
118 | 89 |
isTriggerOnDown <Boolean> controls if the action should be executed on |
582 | 90 |
press or on release (default: on release). |
125 | 91 |
|
92 |
isToggle <Boolean> controls if the button should show toggle |
|
582 | 93 |
behavior (as opposed to one-shot behavior) |
125 | 94 |
|
76 | 95 |
pressActionBlock <Block> block to evaluate when pressed (default: noop) |
125 | 96 |
|
76 | 97 |
releaseActionBlock <Block> block to evaluate when released (default: noop) |
125 | 98 |
|
76 | 99 |
autoRepeat <Boolean> auto-repeats when pressed long enough (default: false) |
125 | 100 |
|
76 | 101 |
initialDelay <Number> seconds till first auto-repeat (default: 0.2) |
125 | 102 |
|
76 | 103 |
repeatDelay <Number> seconds of repeat intervall (default: 0.025) |
125 | 104 |
|
76 | 105 |
repeatBlock <Block> block evaluated for auto-repeat (internal) |
125 | 106 |
|
76 | 107 |
active <Boolean> true during action evaluation (internal) |
582 | 108 |
|
109 |
[author:] |
|
110 |
Claus Gittinger |
|
76 | 111 |
" |
112 |
! ! |
|
113 |
||
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
114 |
!ButtonController class methodsFor:'defaults'! |
76 | 115 |
|
116 |
defaultInitialDelay |
|
117 |
"when autorepeat is enabled, and button is not released, |
|
118 |
start repeating after initialDelay seconds" |
|
119 |
||
120 |
^ 0.2 |
|
200 | 121 |
! |
122 |
||
123 |
defaultRepeatDelay |
|
124 |
"when autorepeat is enabled, and button is not released, |
|
125 |
repeat every repeatDelay seconds" |
|
126 |
||
127 |
^ 0.025 |
|
76 | 128 |
! ! |
129 |
||
200 | 130 |
!ButtonController methodsFor:'accessing-behavior'! |
131 |
||
132 |
action:aBlock |
|
133 |
"convenient method: depending on the setting the triggerOnDown flag, |
|
347 | 134 |
either set the press-action & clear any release-action or |
200 | 135 |
vice versa, set the release-action and clear the press-action." |
76 | 136 |
|
200 | 137 |
isTriggerOnDown ifTrue:[ |
347 | 138 |
releaseActionBlock := nil. |
139 |
pressActionBlock := aBlock |
|
200 | 140 |
] ifFalse:[ |
347 | 141 |
releaseActionBlock := aBlock. |
142 |
pressActionBlock := nil |
|
2865 | 143 |
]. |
347 | 144 |
|
145 |
"Modified: 9.2.1996 / 22:41:22 / cg" |
|
200 | 146 |
! |
118 | 147 |
|
200 | 148 |
autoRepeat |
347 | 149 |
"turn on autorepeat. OBSOLETE; use #autoRepeat:" |
200 | 150 |
|
347 | 151 |
self autoRepeat:true. |
152 |
||
153 |
"Modified: 9.2.1996 / 22:42:46 / cg" |
|
118 | 154 |
! |
155 |
||
200 | 156 |
autoRepeat:aBoolean |
157 |
"turn on/off autorepeat" |
|
158 |
||
159 |
autoRepeat := aBoolean. |
|
1147 | 160 |
repeatBlock := MessageSend receiver:self selector:#repeat. "/ [self repeat] |
121 | 161 |
|
200 | 162 |
"Modified: 5.9.1995 / 22:06:00 / claus" |
1147 | 163 |
"Modified: 20.3.1997 / 21:56:13 / cg" |
200 | 164 |
! |
165 |
||
976 | 166 |
beButton |
5880 | 167 |
"make the receiver act like a button; that's the default, anyway" |
976 | 168 |
|
2345
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
169 |
"/ because I will be a trigger-on-up button |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
170 |
(isTriggerOnDown |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
171 |
and:[pressActionBlock notNil |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
172 |
and:[releaseActionBlock isNil]]) ifTrue:[ |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
173 |
pressActionBlock := releaseActionBlock. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
174 |
releaseActionBlock := nil. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
175 |
]. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
176 |
|
976 | 177 |
isTriggerOnDown := false. |
178 |
isToggle := false. |
|
179 |
isRadio := false. |
|
180 |
||
181 |
"Modified: 15.7.1996 / 13:42:15 / cg" |
|
182 |
"Created: 27.1.1997 / 13:30:11 / cg" |
|
183 |
! |
|
184 |
||
789 | 185 |
beRadioButton |
186 |
"make the receiver act like a radioButton; |
|
187 |
That is like a toggle, but do not allow turning myself off |
|
188 |
by buttonPress (instead, must be turned off by another button or programmatically)" |
|
189 |
||
2345
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
190 |
"/ because I will be a trigger-on-down button |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
191 |
(isTriggerOnDown not |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
192 |
and:[releaseActionBlock notNil |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
193 |
and:[pressActionBlock isNil]]) ifTrue:[ |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
194 |
pressActionBlock := releaseActionBlock. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
195 |
releaseActionBlock := nil. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
196 |
]. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
197 |
|
789 | 198 |
isTriggerOnDown := true. |
199 |
isToggle := false. |
|
200 |
isRadio := true. |
|
201 |
! |
|
202 |
||
200 | 203 |
beToggle |
204 |
"make the receiver act like a toggle" |
|
205 |
||
2345
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
206 |
"/ because I will be a trigger-on-down button |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
207 |
(isTriggerOnDown not |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
208 |
and:[releaseActionBlock notNil |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
209 |
and:[pressActionBlock isNil]]) ifTrue:[ |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
210 |
pressActionBlock := releaseActionBlock. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
211 |
releaseActionBlock := nil. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
212 |
]. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
213 |
|
200 | 214 |
isTriggerOnDown := true. |
789 | 215 |
isToggle := true. |
216 |
isRadio := false. |
|
217 |
||
218 |
"Modified: 15.7.1996 / 13:42:15 / cg" |
|
121 | 219 |
! |
76 | 220 |
|
200 | 221 |
beTriggerOnDown |
222 |
"make the receiver act on button press" |
|
223 |
||
224 |
isTriggerOnDown := true |
|
225 |
! |
|
226 |
||
227 |
beTriggerOnUp |
|
228 |
"make the receiver act on button release" |
|
121 | 229 |
|
200 | 230 |
isTriggerOnDown := false |
231 |
! |
|
232 |
||
233 |
disable |
|
1832 | 234 |
"alternative invokation; redirected to basic mechanism" |
200 | 235 |
|
1832 | 236 |
self enabled:false |
237 |
||
238 |
"Modified: / 30.3.1999 / 14:50:12 / stefan" |
|
121 | 239 |
! |
240 |
||
5880 | 241 |
doubleClickAction |
242 |
"return the doubleClickAction; that's the block which gets evaluated |
|
243 |
when the button is double-clicked (if non-nil). |
|
244 |
Seldom used with buttons" |
|
245 |
||
246 |
^ doubleClickActionBlock |
|
247 |
! |
|
248 |
||
249 |
doubleClickAction:aBlock |
|
250 |
"define the action to be performed on double click" |
|
251 |
||
252 |
doubleClickActionBlock := aBlock. |
|
253 |
! |
|
254 |
||
200 | 255 |
enable |
1832 | 256 |
"alternative invokation; redirected to basic mechanism" |
257 |
||
258 |
self enabled:true |
|
259 |
||
260 |
"Modified: / 30.3.1999 / 14:50:01 / stefan" |
|
261 |
! |
|
121 | 262 |
|
1832 | 263 |
enabled:aBoolean |
264 |
"disable the button" |
|
265 |
||
266 |
enableChannel value ~~ aBoolean ifTrue:[ |
|
267 |
enableChannel value:aBoolean. |
|
268 |
"/ view redraw - not needed; I listen to enableChannel |
|
200 | 269 |
] |
1832 | 270 |
|
271 |
"Created: / 30.3.1999 / 14:49:05 / stefan" |
|
76 | 272 |
! |
273 |
||
200 | 274 |
isTriggerOnDown |
275 |
"return true, if I trigger on press |
|
276 |
(in contrast to triggering on up, which is the default)" |
|
277 |
||
278 |
^ isTriggerOnDown |
|
279 |
! |
|
280 |
||
281 |
pressAction |
|
5880 | 282 |
"return the pressAction; that's the block which gets evaluated |
200 | 283 |
when the button is pressed (if non-nil)" |
284 |
||
285 |
^ pressActionBlock |
|
286 |
! |
|
287 |
||
288 |
pressAction:aBlock |
|
289 |
"define the action to be performed on press" |
|
290 |
||
2865 | 291 |
pressActionBlock := aBlock. |
128 | 292 |
! |
293 |
||
200 | 294 |
releaseAction |
5880 | 295 |
"return the releaseAction; that's the block which gets evaluated |
296 |
when the button is released (if non-nil)" |
|
200 | 297 |
|
298 |
^ releaseActionBlock |
|
299 |
! |
|
300 |
||
301 |
releaseAction:aBlock |
|
302 |
"define the action to be performed on release" |
|
303 |
||
2865 | 304 |
releaseActionBlock := aBlock. |
128 | 305 |
! |
306 |
||
200 | 307 |
triggerOnDown:aBoolean |
308 |
"set/clear the flag which controls if the action block is to be evaluated |
|
309 |
on press or on release. |
|
310 |
(see also ST-80 compatibility methods beTriggerOn*)" |
|
311 |
||
312 |
isTriggerOnDown := aBoolean |
|
128 | 313 |
! ! |
314 |
||
145 | 315 |
!ButtonController methodsFor:'accessing-channels'! |
316 |
||
317 |
enableChannel |
|
602 | 318 |
"return the valueHolder holding the enable boolean value" |
145 | 319 |
|
320 |
^ enableChannel |
|
602 | 321 |
|
322 |
"Modified: 30.4.1996 / 15:09:30 / cg" |
|
145 | 323 |
! |
324 |
||
325 |
enableChannel:aValueHolder |
|
326 |
"set the valueHolder, which holds the enable boolean value" |
|
327 |
||
162 | 328 |
|wasEnabled| |
329 |
||
145 | 330 |
enableChannel notNil ifTrue:[ |
1447 | 331 |
wasEnabled := enableChannel value. |
332 |
enableChannel retractInterestsFor:self. |
|
162 | 333 |
] ifFalse:[ |
1447 | 334 |
wasEnabled := true |
145 | 335 |
]. |
336 |
enableChannel := aValueHolder. |
|
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
337 |
aValueHolder onChangeSend:#enableStateChanged to:self. |
1447 | 338 |
|
162 | 339 |
enableChannel value ~~ wasEnabled ifTrue:[ |
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
340 |
self enableStateChanged |
1447 | 341 |
|
145 | 342 |
] |
162 | 343 |
|
344 |
"Modified: 17.9.1995 / 19:41:18 / claus" |
|
145 | 345 |
! |
346 |
||
2312 | 347 |
pressChannel |
348 |
||
349 |
^ pressChannel |
|
350 |
! |
|
351 |
||
145 | 352 |
pressChannel:aChannel |
353 |
pressChannel := aChannel |
|
354 |
! |
|
355 |
||
2312 | 356 |
releaseChannel |
357 |
||
358 |
^ releaseChannel |
|
359 |
! |
|
360 |
||
145 | 361 |
releaseChannel:aChannel |
362 |
releaseChannel := aChannel |
|
363 |
! ! |
|
364 |
||
200 | 365 |
!ButtonController methodsFor:'accessing-state'! |
76 | 366 |
|
200 | 367 |
active |
368 |
"return true, if I am active; |
|
369 |
that is: currently performing my action. |
|
370 |
This query can be used to avoid multiple redraws." |
|
76 | 371 |
|
200 | 372 |
^ active |
128 | 373 |
! |
374 |
||
200 | 375 |
active:aBoolean |
376 |
active := aBoolean |
|
76 | 377 |
! |
378 |
||
200 | 379 |
enabled |
380 |
"return true, if I am enabled" |
|
128 | 381 |
|
200 | 382 |
^ enableChannel value |
76 | 383 |
! |
384 |
||
200 | 385 |
entered |
386 |
"return true, if the mouse pointer is currently in my view" |
|
155 | 387 |
|
200 | 388 |
^ entered |
389 |
! |
|
155 | 390 |
|
200 | 391 |
entered:aBoolean |
392 |
entered := aBoolean |
|
155 | 393 |
! |
394 |
||
200 | 395 |
pressed |
396 |
"return true, if I am pressed" |
|
76 | 397 |
|
200 | 398 |
^ pressed |
76 | 399 |
! |
400 |
||
200 | 401 |
pressed:aBoolean |
402 |
pressed ~~ aBoolean ifTrue:[ |
|
403 |
pressed := aBoolean. |
|
404 |
self performAction. |
|
118 | 405 |
]. |
406 |
! |
|
407 |
||
200 | 408 |
setPressed:aBoolean |
409 |
pressed := aBoolean. |
|
121 | 410 |
|
200 | 411 |
"Created: 14.11.1995 / 21:37:08 / cg" |
266 | 412 |
! |
413 |
||
414 |
toggle |
|
415 |
"toggle and perform the action" |
|
416 |
||
417 |
enableChannel value ifTrue:[ |
|
2312 | 418 |
self toggleNoAction. |
419 |
self performAction. |
|
420 |
view changed:#toggle with:pressed |
|
266 | 421 |
] |
422 |
! |
|
423 |
||
424 |
toggleNoAction |
|
425 |
"toggle, but do NOT perform any action" |
|
426 |
||
427 |
pressed ifTrue:[ |
|
1463
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
428 |
view turnOff. |
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
429 |
pressed := false. |
266 | 430 |
] ifFalse:[ |
1463
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
431 |
view turnOn. |
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
432 |
pressed := true. |
266 | 433 |
]. |
1463
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
434 |
view repairDamage |
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
435 |
|
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
436 |
"Modified: / 4.3.1998 / 13:35:12 / cg" |
76 | 437 |
! ! |
438 |
||
439 |
!ButtonController methodsFor:'event handling'! |
|
440 |
||
2382 | 441 |
buttonMotion:buttonState x:x y:y |
1266 | 442 |
(x >= 0 and:[x < view width |
443 |
and:[y >= 0 and:[y < view height]]]) ifTrue:[ |
|
444 |
entered ifFalse:[ |
|
2382 | 445 |
self pointerEnter:buttonState x:x y:y |
446 |
] |
|
1266 | 447 |
] ifFalse:[ |
448 |
entered ifTrue:[ |
|
2382 | 449 |
self pointerLeave:buttonState |
450 |
] |
|
1266 | 451 |
] |
452 |
! |
|
453 |
||
200 | 454 |
buttonMultiPress:button x:x y:y |
5880 | 455 |
doubleClickActionBlock notNil ifTrue:[ |
456 |
doubleClickActionBlock valueWithOptionalArgument:view. |
|
457 |
^ self. |
|
458 |
]. |
|
200 | 459 |
^ self buttonPress:button x:x y:y |
460 |
! |
|
461 |
||
76 | 462 |
buttonPress:button x:x y:y |
1710 | 463 |
|wg| |
464 |
||
5075 | 465 |
"/ simulate momentary loss of focus to force accept into models in other components |
466 |
wg := view windowGroup. |
|
467 |
wg notNil ifTrue:[ |
|
468 |
wg focusMomentaryRelease. |
|
76 | 469 |
]. |
470 |
||
5075 | 471 |
(button == 1) ifFalse:[ |
472 |
^ super buttonPress:button x:x y:y |
|
1680
4c01dc0d5f1c
optional take focus on click
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
473 |
]. |
4c01dc0d5f1c
optional take focus on click
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
474 |
|
1128 | 475 |
buttonDown := true. |
476 |
||
133 | 477 |
enableChannel value ifTrue:[ |
789 | 478 |
isToggle ifTrue:[ |
479 |
self toggle. |
|
480 |
^ self |
|
481 |
]. |
|
482 |
isRadio ifTrue:[ |
|
483 |
pressed ifFalse:[ |
|
484 |
self toggle |
|
485 |
]. |
|
486 |
^ self |
|
487 |
]. |
|
118 | 488 |
|
789 | 489 |
pressed ifFalse:[ |
490 |
pressed := true. |
|
491 |
view showActive. |
|
5645 | 492 |
"/ make sure that a momentary press is visible |
493 |
view repairDamage. |
|
494 |
Delay waitForSeconds:0.1. |
|
76 | 495 |
|
789 | 496 |
(pressActionBlock notNil or:[model notNil]) ifTrue:[ |
497 |
" |
|
498 |
force output - so that button is drawn correctly in case |
|
499 |
of any long-computation (at high priority) |
|
500 |
" |
|
501 |
view flush. |
|
502 |
]. |
|
76 | 503 |
|
789 | 504 |
self performAction. |
2962 | 505 |
view notNil ifTrue:[ |
506 |
view flush. |
|
507 |
]. |
|
76 | 508 |
|
789 | 509 |
autoRepeat ifTrue:[ |
510 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
|
511 |
] |
|
512 |
] |
|
76 | 513 |
] |
262 | 514 |
|
4412 | 515 |
"Modified: / 28-03-2012 / 13:08:38 / cg" |
76 | 516 |
! |
517 |
||
518 |
buttonRelease:button x:x y:y |
|
519 |
"button was released - if enabled, perform releaseaction" |
|
520 |
||
3918
b00bc734f3d8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3849
diff
changeset
|
521 |
(button == 1) ifFalse:[ |
789 | 522 |
^ super buttonRelease:button x:x y:y |
76 | 523 |
]. |
118 | 524 |
|
1128 | 525 |
buttonDown := false. |
526 |
||
789 | 527 |
(isToggle or:[isRadio]) ifTrue:[ |
528 |
^ self |
|
118 | 529 |
]. |
530 |
||
76 | 531 |
pressed ifTrue:[ |
789 | 532 |
autoRepeat ifTrue:[ |
533 |
Processor removeTimedBlock:repeatBlock |
|
534 |
]. |
|
535 |
pressed := false. |
|
536 |
view showPassive. |
|
76 | 537 |
|
789 | 538 |
enableChannel value ifTrue:[ |
539 |
" |
|
540 |
only perform action if released within myself |
|
541 |
" |
|
542 |
((x >= 0) |
|
543 |
and:[x <= view width |
|
544 |
and:[y >= 0 |
|
545 |
and:[y <= view height]]]) ifTrue:[ |
|
546 |
(releaseActionBlock notNil or:[model notNil]) ifTrue:[ |
|
547 |
" |
|
548 |
force output - so that button is drawn correctly in case |
|
549 |
of any long-computation (at high priority) |
|
550 |
" |
|
551 |
view flush. |
|
552 |
]. |
|
76 | 553 |
|
789 | 554 |
self performAction. |
555 |
] |
|
556 |
] |
|
76 | 557 |
] |
262 | 558 |
|
1128 | 559 |
"Modified: 8.3.1997 / 00:04:19 / cg" |
76 | 560 |
! |
561 |
||
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
562 |
enableStateChanged |
200 | 563 |
"this is sent, whenever the enable value has changed" |
76 | 564 |
|
1779
cd68cec6ebe8
change the cursor for disabled buttons.
Claus Gittinger <cg@exept.de>
parents:
1739
diff
changeset
|
565 |
view notNil ifTrue:[ |
cd68cec6ebe8
change the cursor for disabled buttons.
Claus Gittinger <cg@exept.de>
parents:
1739
diff
changeset
|
566 |
view invalidate "redraw". |
3849
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
567 |
view |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
568 |
cursor:( |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
569 |
enableChannel value |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
570 |
ifTrue:[ Cursor hand ] |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
571 |
ifFalse:[ Cursor normal ]) |
1779
cd68cec6ebe8
change the cursor for disabled buttons.
Claus Gittinger <cg@exept.de>
parents:
1739
diff
changeset
|
572 |
] |
200 | 573 |
|
574 |
"Modified: 17.9.1995 / 19:55:52 / claus" |
|
1191
98386e90229f
use asynchronous #invalidate when enable-state changes.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
575 |
"Modified: 17.4.1997 / 01:53:14 / cg" |
76 | 576 |
! |
577 |
||
200 | 578 |
keyPress:key x:x y:y |
579 |
"trigger on Return and space, if I am the focusView of my group |
|
580 |
(i.e. if I got an explicit focus)" |
|
121 | 581 |
|
4488 | 582 |
"/ <resource: #keyboard (#Return)> |
3224 | 583 |
|
5323 | 584 |
|simulateClick| |
585 |
||
3803 | 586 |
view hasExplicitFocus ifTrue:[ |
5323 | 587 |
simulateClick := false. |
588 |
simulateClick := (key == Character space). |
|
589 |
simulateClick ifFalse:[ |
|
590 |
((key == #Return) and:[ isToggle not and:[isRadio not]]) ifTrue:[ |
|
591 |
simulateClick := true. |
|
592 |
]. |
|
593 |
]. |
|
594 |
||
595 |
simulateClick ifTrue:[ |
|
349
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
596 |
"just simulate a buttonPress/release here." |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
597 |
self buttonPress:1 x:0 y:0. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
598 |
self buttonRelease:1 x:0 y:0. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
599 |
^ self. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
600 |
] |
200 | 601 |
]. |
602 |
view keyPress:key x:x y:y |
|
349
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
603 |
|
4393 | 604 |
"Modified: / 07-03-2012 / 11:47:40 / cg" |
121 | 605 |
! |
606 |
||
607 |
performAction |
|
146 | 608 |
|action value| |
133 | 609 |
|
789 | 610 |
(isToggle or:[isRadio]) ifTrue:[ |
611 |
value := pressed |
|
133 | 612 |
] ifFalse:[ |
789 | 613 |
value := true |
133 | 614 |
]. |
76 | 615 |
|
125 | 616 |
" |
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
617 |
ST-80 style model notification ... |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
618 |
this updates the model (typically, a ValueHolder) |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
619 |
" |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
620 |
(isToggle |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
621 |
or:[(isTriggerOnDown and:[pressed]) |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
622 |
or:[isTriggerOnDown not and:[pressed not]]]) ifTrue:[ |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
623 |
"the ST-80 way of doing things" |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
624 |
view notNil ifTrue:[ |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
625 |
active := true. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
626 |
view sendChangeMessageWith:value. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
627 |
active := false. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
628 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
629 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
630 |
|
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
631 |
" |
145 | 632 |
ST/X style actionBlock evaluation & channel notification ... |
125 | 633 |
" |
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
634 |
pressChannel notNil ifTrue:[ |
1095 | 635 |
pressed ifTrue:[ |
636 |
pressChannel value:true |
|
637 |
] |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
638 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
639 |
releaseChannel notNil ifTrue:[ |
1095 | 640 |
pressed ifFalse:[ |
641 |
releaseChannel value:true |
|
642 |
] |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
643 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
644 |
|
76 | 645 |
pressed ifTrue:[ |
789 | 646 |
action := pressActionBlock. |
121 | 647 |
] ifFalse:[ |
789 | 648 |
action := releaseActionBlock. |
121 | 649 |
]. |
2865 | 650 |
|
125 | 651 |
action notNil ifTrue:[ |
789 | 652 |
active := true. |
2501 | 653 |
action valueWithOptionalArgument:value. |
789 | 654 |
active := false. |
125 | 655 |
]. |
76 | 656 |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
657 |
"Modified: 24.1.1997 / 11:38:20 / cg" |
76 | 658 |
! |
659 |
||
2308 | 660 |
performShortcutAction |
661 |
enableChannel value ifTrue:[ |
|
662 |
isToggle ifTrue:[ |
|
663 |
self toggle. |
|
664 |
^ self |
|
665 |
]. |
|
666 |
isRadio ifTrue:[ |
|
667 |
pressed ifFalse:[ |
|
668 |
self toggle |
|
669 |
]. |
|
670 |
^ self |
|
671 |
]. |
|
672 |
||
673 |
self performAction. |
|
2312 | 674 |
] |
675 |
! |
|
2308 | 676 |
|
200 | 677 |
pointerEnter:state x:x y:y |
678 |
"mouse pointer entered my view. |
|
679 |
Redraw with enteredColors if they differ from the normal colors" |
|
680 |
||
681 |
entered := true. |
|
682 |
enableChannel value ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
683 |
pressed ifTrue:[ |
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
684 |
isTriggerOnDown ifFalse:[ |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
685 |
view showActive. |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
686 |
]. |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
687 |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
688 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
689 |
reentered after a leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
690 |
restart autorepeating and/or if I am a button with |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
691 |
triggerOnDown, show active again. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
692 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
693 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
694 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
695 |
]. |
3849
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
696 |
]. |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
697 |
view invalidate |
200 | 698 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
699 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
700 |
"Modified: 26.5.1996 / 18:09:06 / cg" |
76 | 701 |
! |
702 |
||
200 | 703 |
pointerLeave:state |
704 |
"mouse pointer left my view. |
|
705 |
Redraw with normal colors if they differ from enteredColors" |
|
76 | 706 |
|
200 | 707 |
entered := false. |
3471
24a5f40ff045
changed #pointerLeave: test for none nil view
Michael Beyl <mb@exept.de>
parents:
3224
diff
changeset
|
708 |
"/ sometimes could happen that the view becomes nil |
24a5f40ff045
changed #pointerLeave: test for none nil view
Michael Beyl <mb@exept.de>
parents:
3224
diff
changeset
|
709 |
view isNil ifTrue:[^ self]. |
24a5f40ff045
changed #pointerLeave: test for none nil view
Michael Beyl <mb@exept.de>
parents:
3224
diff
changeset
|
710 |
|
200 | 711 |
pressed ifTrue:[ |
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
712 |
isTriggerOnDown ifFalse:[ |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
713 |
view showPassive. |
1168
231969f02a78
also invalidate in leave if not pressed
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
714 |
] ifTrue:[ |
231969f02a78
also invalidate in leave if not pressed
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
715 |
view invalidate |
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
716 |
]. |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
717 |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
718 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
719 |
leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
720 |
stop autorepeating and/or if I am a button with |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
721 |
action on release, show passive |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
722 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
723 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
724 |
Processor removeTimedBlock:repeatBlock |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
725 |
]. |
3849
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
726 |
]. |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
727 |
enableChannel value ifTrue:[ |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
728 |
view invalidate |
200 | 729 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
730 |
|
1168
231969f02a78
also invalidate in leave if not pressed
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
731 |
"Modified: 1.4.1997 / 13:27:32 / cg" |
76 | 732 |
! |
733 |
||
121 | 734 |
repeat |
735 |
"this is sent from the autorepeat-block, when the button has been pressed long |
|
736 |
enough; it simulates a release-press, by evaluating both release |
|
737 |
and press actions." |
|
76 | 738 |
|
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
739 |
|dly| |
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
740 |
|
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
741 |
(pressed and:[entered]) ifTrue:[ |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
742 |
enableChannel value ifTrue:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
743 |
active ifFalse:[ |
5584 | 744 |
"/ don't repeat, if a release is pending ... |
2004
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
745 |
"/ (must check this, because the release event could |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
746 |
"/ stick in the queue, since exposes are handled first, |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
747 |
"/ which could lead to event processing to never happen) |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
748 |
(view sensor hasButtonReleaseEventFor:view) ifFalse:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
749 |
self performAction. |
121 | 750 |
|
2004
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
751 |
autoRepeat ifTrue:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
752 |
view graphicsDevice shiftDown ifTrue:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
753 |
dly := repeatDelay / 4. |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
754 |
] ifFalse:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
755 |
dly := repeatDelay |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
756 |
]. |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
757 |
Processor addTimedBlock:repeatBlock afterSeconds:dly |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
758 |
] |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
759 |
] |
2865 | 760 |
]. |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
761 |
] |
76 | 762 |
] |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
763 |
|
704 | 764 |
"Modified: 28.5.1996 / 20:21:24 / cg" |
1783 | 765 |
! |
766 |
||
767 |
requestAutoAccept |
|
5069 | 768 |
"request to autoAccept from a keyboardProcessor. |
5074 | 769 |
AutoAccept is always allowed" |
1783 | 770 |
|
2283 | 771 |
^ true. |
5074 | 772 |
"/ used to be: |
773 |
"/ ^ self enabled and:[view isDefault] |
|
76 | 774 |
! ! |
121 | 775 |
|
776 |
!ButtonController methodsFor:'initialization'! |
|
777 |
||
1266 | 778 |
controlInitialize |
779 |
active := false. |
|
780 |
entered := false. |
|
781 |
||
782 |
"Created: 24.7.1997 / 14:58:28 / cg" |
|
783 |
"Modified: 24.7.1997 / 14:59:06 / cg" |
|
784 |
! |
|
785 |
||
121 | 786 |
initialize |
787 |
super initialize. |
|
788 |
||
1540 | 789 |
enableChannel := ValueHolder with:true. |
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
790 |
enableChannel onChangeSend:#enableStateChanged to:self. |
133 | 791 |
|
121 | 792 |
active := false. |
793 |
pressed := false. |
|
794 |
entered := false. |
|
795 |
autoRepeat := false. |
|
796 |
initialDelay := self class defaultInitialDelay. |
|
797 |
repeatDelay := self class defaultRepeatDelay. |
|
798 |
isTriggerOnDown := false. |
|
789 | 799 |
isToggle := isRadio := false. |
800 |
||
1540 | 801 |
"Modified: / 21.5.1998 / 03:07:02 / cg" |
1447 | 802 |
! |
803 |
||
1739 | 804 |
reinitialize |
805 |
active := false. |
|
2166
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
806 |
(isToggle or:[isRadio]) ifFalse:[ |
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
807 |
pressed := false. |
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
808 |
]. |
1739 | 809 |
entered := false. |
2166
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
810 |
|
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
811 |
"Modified: / 1.3.2000 / 15:17:10 / cg" |
1739 | 812 |
! |
813 |
||
1447 | 814 |
release |
815 |
"release all dependencies" |
|
816 |
||
817 |
enableChannel notNil ifTrue:[ |
|
818 |
enableChannel retractInterestsFor:self. |
|
819 |
enableChannel := nil. |
|
820 |
]. |
|
821 |
super release |
|
121 | 822 |
! ! |
200 | 823 |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
824 |
!ButtonController class methodsFor:'documentation'! |
203 | 825 |
|
826 |
version |
|
5584 | 827 |
^ '$Header$' |
203 | 828 |
! ! |
4488 | 829 |