author | Claus Gittinger <cg@exept.de> |
Tue, 28 May 1996 22:11:10 +0200 | |
changeset 711 | c830bb66598b |
parent 704 | 5989a3af6207 |
child 789 | d1603717af51 |
permissions | -rw-r--r-- |
76 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
Controller subclass:#ButtonController |
|
262 | 14 |
instanceVariableNames:'enableChannel pressChannel releaseChannel pressed active entered |
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
15 |
isTriggerOnDown autoRepeat repeatBlock initialDelay repeatDelay |
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
16 |
pressActionBlock releaseActionBlock isToggle' |
262 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Support-Controllers' |
|
76 | 20 |
! |
21 |
||
22 |
!ButtonController class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
ButtonControllers are used with buttons and handle all user interaction. |
|
41 |
These are automatically created when a Button is created, therefore no manual |
|
42 |
action is required for creation. |
|
133 | 43 |
In normal applications, you dont have to care for the controller; |
44 |
access to the controllers behavior is possible via messages to the button. |
|
125 | 45 |
(setting actions, controlling autorepeat etc.) |
76 | 46 |
|
133 | 47 |
See examples in the Button class. |
48 |
||
582 | 49 |
[Instance variables:] |
76 | 50 |
|
133 | 51 |
enableChannel <ValueHolder pressing is allowed (default: true) |
582 | 52 |
on Boolean> |
125 | 53 |
|
76 | 54 |
pressed <Boolean> true if currently pressed (read-only) |
125 | 55 |
|
76 | 56 |
entered <Boolean> true if the cursor is currently in this view |
125 | 57 |
|
118 | 58 |
isTriggerOnDown <Boolean> controls if the action should be executed on |
582 | 59 |
press or on release (default: on release). |
125 | 60 |
|
61 |
isToggle <Boolean> controls if the button should show toggle |
|
582 | 62 |
behavior (as opposed to one-shot behavior) |
125 | 63 |
|
76 | 64 |
pressActionBlock <Block> block to evaluate when pressed (default: noop) |
125 | 65 |
|
76 | 66 |
releaseActionBlock <Block> block to evaluate when released (default: noop) |
125 | 67 |
|
76 | 68 |
autoRepeat <Boolean> auto-repeats when pressed long enough (default: false) |
125 | 69 |
|
76 | 70 |
initialDelay <Number> seconds till first auto-repeat (default: 0.2) |
125 | 71 |
|
76 | 72 |
repeatDelay <Number> seconds of repeat intervall (default: 0.025) |
125 | 73 |
|
76 | 74 |
repeatBlock <Block> block evaluated for auto-repeat (internal) |
125 | 75 |
|
76 | 76 |
active <Boolean> true during action evaluation (internal) |
582 | 77 |
|
78 |
[author:] |
|
79 |
Claus Gittinger |
|
76 | 80 |
" |
81 |
! ! |
|
82 |
||
83 |
!ButtonController class methodsFor:'defaults'! |
|
84 |
||
85 |
defaultInitialDelay |
|
86 |
"when autorepeat is enabled, and button is not released, |
|
87 |
start repeating after initialDelay seconds" |
|
88 |
||
89 |
^ 0.2 |
|
200 | 90 |
! |
91 |
||
92 |
defaultRepeatDelay |
|
93 |
"when autorepeat is enabled, and button is not released, |
|
94 |
repeat every repeatDelay seconds" |
|
95 |
||
96 |
^ 0.025 |
|
76 | 97 |
! ! |
98 |
||
200 | 99 |
!ButtonController methodsFor:'accessing-behavior'! |
100 |
||
101 |
action:aBlock |
|
102 |
"convenient method: depending on the setting the triggerOnDown flag, |
|
347 | 103 |
either set the press-action & clear any release-action or |
200 | 104 |
vice versa, set the release-action and clear the press-action." |
76 | 105 |
|
200 | 106 |
isTriggerOnDown ifTrue:[ |
347 | 107 |
releaseActionBlock := nil. |
108 |
pressActionBlock := aBlock |
|
200 | 109 |
] ifFalse:[ |
347 | 110 |
releaseActionBlock := aBlock. |
111 |
pressActionBlock := nil |
|
200 | 112 |
] |
347 | 113 |
|
114 |
"Modified: 9.2.1996 / 22:41:22 / cg" |
|
200 | 115 |
! |
118 | 116 |
|
200 | 117 |
autoRepeat |
347 | 118 |
"turn on autorepeat. OBSOLETE; use #autoRepeat:" |
200 | 119 |
|
347 | 120 |
self autoRepeat:true. |
121 |
||
122 |
"Modified: 9.2.1996 / 22:42:46 / cg" |
|
118 | 123 |
! |
124 |
||
200 | 125 |
autoRepeat:aBoolean |
126 |
"turn on/off autorepeat" |
|
127 |
||
128 |
autoRepeat := aBoolean. |
|
129 |
repeatBlock := [self repeat] |
|
121 | 130 |
|
200 | 131 |
"Modified: 5.9.1995 / 22:06:00 / claus" |
132 |
! |
|
133 |
||
134 |
beToggle |
|
135 |
"make the receiver act like a toggle" |
|
136 |
||
137 |
isTriggerOnDown := true. |
|
138 |
isToggle := true |
|
121 | 139 |
! |
76 | 140 |
|
200 | 141 |
beTriggerOnDown |
142 |
"make the receiver act on button press" |
|
143 |
||
144 |
isTriggerOnDown := true |
|
145 |
! |
|
146 |
||
147 |
beTriggerOnUp |
|
148 |
"make the receiver act on button release" |
|
121 | 149 |
|
200 | 150 |
isTriggerOnDown := false |
151 |
! |
|
152 |
||
153 |
disable |
|
154 |
"disable the button" |
|
155 |
||
156 |
enableChannel value ifTrue:[ |
|
157 |
enableChannel value:false. |
|
158 |
"/ view redraw - not needed; I listen to enableChannel |
|
159 |
] |
|
121 | 160 |
! |
161 |
||
200 | 162 |
enable |
163 |
"enable the button" |
|
121 | 164 |
|
200 | 165 |
enableChannel value ifFalse:[ |
166 |
enableChannel value:true. |
|
167 |
"/ view redraw - not needed; I listen to enableChannel |
|
168 |
] |
|
76 | 169 |
! |
170 |
||
200 | 171 |
isTriggerOnDown |
172 |
"return true, if I trigger on press |
|
173 |
(in contrast to triggering on up, which is the default)" |
|
174 |
||
175 |
^ isTriggerOnDown |
|
176 |
! |
|
177 |
||
178 |
pressAction |
|
179 |
"return the pressAction; thats the block which gets evaluated |
|
180 |
when the button is pressed (if non-nil)" |
|
181 |
||
182 |
^ pressActionBlock |
|
183 |
! |
|
184 |
||
185 |
pressAction:aBlock |
|
186 |
"define the action to be performed on press" |
|
187 |
||
188 |
pressActionBlock := aBlock |
|
128 | 189 |
! |
190 |
||
200 | 191 |
releaseAction |
192 |
"return the releaseAction; thats the block which gets evaluated |
|
193 |
when the button is relreased (if non-nil)" |
|
194 |
||
195 |
^ releaseActionBlock |
|
196 |
! |
|
197 |
||
198 |
releaseAction:aBlock |
|
199 |
"define the action to be performed on release" |
|
200 |
||
201 |
releaseActionBlock := aBlock |
|
128 | 202 |
! |
203 |
||
200 | 204 |
triggerOnDown:aBoolean |
205 |
"set/clear the flag which controls if the action block is to be evaluated |
|
206 |
on press or on release. |
|
207 |
(see also ST-80 compatibility methods beTriggerOn*)" |
|
208 |
||
209 |
isTriggerOnDown := aBoolean |
|
128 | 210 |
! ! |
211 |
||
145 | 212 |
!ButtonController methodsFor:'accessing-channels'! |
213 |
||
214 |
enableChannel |
|
602 | 215 |
"return the valueHolder holding the enable boolean value" |
145 | 216 |
|
217 |
^ enableChannel |
|
602 | 218 |
|
219 |
"Modified: 30.4.1996 / 15:09:30 / cg" |
|
145 | 220 |
! |
221 |
||
222 |
enableChannel:aValueHolder |
|
223 |
"set the valueHolder, which holds the enable boolean value" |
|
224 |
||
162 | 225 |
|wasEnabled| |
226 |
||
145 | 227 |
enableChannel notNil ifTrue:[ |
162 | 228 |
wasEnabled := enableChannel value. |
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
220
diff
changeset
|
229 |
enableChannel retractInterestsFor:self. |
162 | 230 |
] ifFalse:[ |
231 |
wasEnabled := true |
|
145 | 232 |
]. |
233 |
enableChannel := aValueHolder. |
|
234 |
aValueHolder onChangeSend:#enableStateChange to:self. |
|
162 | 235 |
enableChannel value ~~ wasEnabled ifTrue:[ |
236 |
self enableStateChange |
|
145 | 237 |
] |
162 | 238 |
|
239 |
"Modified: 17.9.1995 / 19:41:18 / claus" |
|
145 | 240 |
! |
241 |
||
242 |
pressChannel:aChannel |
|
243 |
pressChannel := aChannel |
|
244 |
! |
|
245 |
||
246 |
releaseChannel:aChannel |
|
247 |
releaseChannel := aChannel |
|
248 |
! ! |
|
249 |
||
200 | 250 |
!ButtonController methodsFor:'accessing-state'! |
76 | 251 |
|
200 | 252 |
active |
253 |
"return true, if I am active; |
|
254 |
that is: currently performing my action. |
|
255 |
This query can be used to avoid multiple redraws." |
|
76 | 256 |
|
200 | 257 |
^ active |
128 | 258 |
! |
259 |
||
200 | 260 |
active:aBoolean |
261 |
active := aBoolean |
|
76 | 262 |
! |
263 |
||
200 | 264 |
enabled |
265 |
"return true, if I am enabled" |
|
128 | 266 |
|
200 | 267 |
^ enableChannel value |
76 | 268 |
! |
269 |
||
200 | 270 |
entered |
271 |
"return true, if the mouse pointer is currently in my view" |
|
155 | 272 |
|
200 | 273 |
^ entered |
274 |
! |
|
155 | 275 |
|
200 | 276 |
entered:aBoolean |
277 |
entered := aBoolean |
|
155 | 278 |
! |
279 |
||
200 | 280 |
pressed |
281 |
"return true, if I am pressed" |
|
76 | 282 |
|
200 | 283 |
^ pressed |
76 | 284 |
! |
285 |
||
200 | 286 |
pressed:aBoolean |
287 |
pressed ~~ aBoolean ifTrue:[ |
|
288 |
pressed := aBoolean. |
|
289 |
self performAction. |
|
118 | 290 |
]. |
291 |
! |
|
292 |
||
200 | 293 |
setPressed:aBoolean |
294 |
pressed := aBoolean. |
|
121 | 295 |
|
200 | 296 |
"Created: 14.11.1995 / 21:37:08 / cg" |
266 | 297 |
! |
298 |
||
299 |
toggle |
|
300 |
"toggle and perform the action" |
|
301 |
||
302 |
enableChannel value ifTrue:[ |
|
303 |
self toggleNoAction. |
|
304 |
self performAction. |
|
305 |
view changed:#toggle with:pressed |
|
306 |
] |
|
307 |
! |
|
308 |
||
309 |
toggleNoAction |
|
310 |
"toggle, but do NOT perform any action" |
|
311 |
||
312 |
pressed ifTrue:[ |
|
313 |
view turnOff. |
|
314 |
pressed := false. |
|
315 |
] ifFalse:[ |
|
316 |
view turnOn. |
|
317 |
pressed := true. |
|
318 |
]. |
|
76 | 319 |
! ! |
320 |
||
321 |
!ButtonController methodsFor:'event handling'! |
|
322 |
||
200 | 323 |
buttonMultiPress:button x:x y:y |
324 |
^ self buttonPress:button x:x y:y |
|
325 |
! |
|
326 |
||
76 | 327 |
buttonPress:button x:x y:y |
328 |
(button == 1 or:[button == #select]) ifFalse:[ |
|
266 | 329 |
^ super buttonPress:button x:x y:y |
76 | 330 |
]. |
331 |
||
133 | 332 |
enableChannel value ifTrue:[ |
266 | 333 |
isToggle ifTrue:[ |
334 |
self toggle. |
|
335 |
^ self |
|
336 |
]. |
|
118 | 337 |
|
266 | 338 |
pressed ifFalse:[ |
339 |
pressed := true. |
|
340 |
view showActive. |
|
76 | 341 |
|
266 | 342 |
(pressActionBlock notNil or:[model notNil]) ifTrue:[ |
343 |
" |
|
344 |
force output - so that button is drawn correctly in case |
|
345 |
of any long-computation (at high priority) |
|
346 |
" |
|
347 |
view flush. |
|
348 |
]. |
|
76 | 349 |
|
266 | 350 |
self performAction. |
76 | 351 |
|
266 | 352 |
autoRepeat ifTrue:[ |
353 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
|
354 |
] |
|
355 |
] |
|
76 | 356 |
] |
262 | 357 |
|
358 |
"Modified: 16.12.1995 / 17:31:55 / cg" |
|
76 | 359 |
! |
360 |
||
361 |
buttonRelease:button x:x y:y |
|
362 |
"button was released - if enabled, perform releaseaction" |
|
363 |
||
364 |
(button == 1 or:[button == #select]) ifFalse:[ |
|
266 | 365 |
^ super buttonRelease:button x:x y:y |
76 | 366 |
]. |
118 | 367 |
|
368 |
isToggle ifTrue:[ |
|
266 | 369 |
^ self |
118 | 370 |
]. |
371 |
||
76 | 372 |
pressed ifTrue:[ |
266 | 373 |
autoRepeat ifTrue:[ |
374 |
Processor removeTimedBlock:repeatBlock |
|
375 |
]. |
|
376 |
pressed := false. |
|
377 |
view showPassive. |
|
76 | 378 |
|
266 | 379 |
enableChannel value ifTrue:[ |
380 |
" |
|
381 |
only perform action if released within myself |
|
382 |
" |
|
383 |
((x >= 0) |
|
384 |
and:[x <= view width |
|
385 |
and:[y >= 0 |
|
386 |
and:[y <= view height]]]) ifTrue:[ |
|
387 |
(releaseActionBlock notNil or:[model notNil]) ifTrue:[ |
|
388 |
" |
|
389 |
force output - so that button is drawn correctly in case |
|
390 |
of any long-computation (at high priority) |
|
391 |
" |
|
392 |
view flush. |
|
393 |
]. |
|
76 | 394 |
|
266 | 395 |
self performAction. |
396 |
] |
|
397 |
] |
|
76 | 398 |
] |
262 | 399 |
|
400 |
"Modified: 16.12.1995 / 17:32:09 / cg" |
|
76 | 401 |
! |
402 |
||
200 | 403 |
enableStateChange |
404 |
"this is sent, whenever the enable value has changed" |
|
76 | 405 |
|
200 | 406 |
view notNil ifTrue:[view enableStateChangeRedraw] |
407 |
||
408 |
"Modified: 17.9.1995 / 19:55:52 / claus" |
|
76 | 409 |
! |
410 |
||
200 | 411 |
keyPress:key x:x y:y |
412 |
"trigger on Return and space, if I am the focusView of my group |
|
413 |
(i.e. if I got an explicit focus)" |
|
121 | 414 |
|
349
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
415 |
key == Character space ifTrue:[ |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
416 |
view hasFocus ifTrue:[ |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
417 |
"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
|
418 |
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
|
419 |
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
|
420 |
^ self. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
421 |
] |
200 | 422 |
]. |
423 |
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
|
424 |
|
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
425 |
"Modified: 9.2.1996 / 23:11:58 / cg" |
121 | 426 |
! |
427 |
||
428 |
performAction |
|
146 | 429 |
|action value| |
133 | 430 |
|
431 |
isToggle ifTrue:[ |
|
432 |
value := pressed |
|
433 |
] ifFalse:[ |
|
434 |
value := true |
|
435 |
]. |
|
76 | 436 |
|
125 | 437 |
" |
145 | 438 |
ST/X style actionBlock evaluation & channel notification ... |
125 | 439 |
" |
76 | 440 |
pressed ifTrue:[ |
145 | 441 |
action := pressActionBlock. |
121 | 442 |
] ifFalse:[ |
145 | 443 |
action := releaseActionBlock. |
121 | 444 |
]. |
125 | 445 |
action notNil ifTrue:[ |
446 |
active := true. |
|
447 |
action numArgs == 0 ifTrue:[ |
|
448 |
action value |
|
449 |
] ifFalse:[ |
|
133 | 450 |
action value:value |
125 | 451 |
]. |
452 |
active := false. |
|
453 |
]. |
|
146 | 454 |
pressChannel notNil ifTrue:[ |
455 |
pressChannel value:pressed |
|
456 |
]. |
|
457 |
releaseChannel notNil ifTrue:[ |
|
458 |
releaseChannel value:pressed not |
|
145 | 459 |
]. |
76 | 460 |
|
125 | 461 |
" |
462 |
ST-80 style model notification ... |
|
463 |
" |
|
121 | 464 |
(isToggle |
465 |
or:[(isTriggerOnDown and:[pressed]) |
|
466 |
or:[isTriggerOnDown not and:[pressed not]]]) ifTrue:[ |
|
125 | 467 |
"the ST-80 way of doing things" |
468 |
view notNil ifTrue:[ |
|
469 |
active := true. |
|
133 | 470 |
view sendChangeMessageWith:value. |
125 | 471 |
active := false. |
472 |
]. |
|
121 | 473 |
]. |
76 | 474 |
! |
475 |
||
200 | 476 |
pointerEnter:state x:x y:y |
477 |
"mouse pointer entered my view. |
|
478 |
Redraw with enteredColors if they differ from the normal colors" |
|
479 |
||
480 |
entered := true. |
|
481 |
enableChannel value ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
482 |
pressed ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
483 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
484 |
reentered after a leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
485 |
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
|
486 |
triggerOnDown, show active again. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
487 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
488 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
489 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
490 |
]. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
491 |
isTriggerOnDown ifFalse:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
492 |
view showActive. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
493 |
] |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
494 |
] ifFalse:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
495 |
view invalidate |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
496 |
] |
200 | 497 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
498 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
499 |
"Modified: 26.5.1996 / 18:09:06 / cg" |
76 | 500 |
! |
501 |
||
200 | 502 |
pointerLeave:state |
503 |
"mouse pointer left my view. |
|
504 |
Redraw with normal colors if they differ from enteredColors" |
|
76 | 505 |
|
200 | 506 |
entered := false. |
507 |
pressed ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
508 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
509 |
leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
510 |
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
|
511 |
action on release, show passive |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
512 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
513 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
514 |
Processor removeTimedBlock:repeatBlock |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
515 |
]. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
516 |
isTriggerOnDown ifFalse:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
517 |
view showPassive. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
518 |
] |
200 | 519 |
] ifFalse:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
520 |
enableChannel value ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
521 |
view invalidate |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
522 |
] |
200 | 523 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
524 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
525 |
"Modified: 26.5.1996 / 18:09:08 / cg" |
76 | 526 |
! |
527 |
||
121 | 528 |
repeat |
529 |
"this is sent from the autorepeat-block, when the button has been pressed long |
|
530 |
enough; it simulates a release-press, by evaluating both release |
|
531 |
and press actions." |
|
76 | 532 |
|
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
533 |
|dly| |
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
534 |
|
76 | 535 |
pressed ifTrue:[ |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
536 |
enableChannel value ifTrue:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
537 |
active ifFalse:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
538 |
self performAction. |
155 | 539 |
"/ active := true. |
540 |
"/ releaseActionBlock notNil ifTrue:[releaseActionBlock value]. |
|
541 |
"/ pressActionBlock notNil ifTrue:[pressActionBlock value]. |
|
542 |
"/ active := false. |
|
121 | 543 |
|
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
544 |
autoRepeat ifTrue:[ |
704 | 545 |
view graphicsDevice shiftDown ifTrue:[ |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
546 |
dly := repeatDelay / 4. |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
547 |
] ifFalse:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
548 |
dly := repeatDelay |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
549 |
]. |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
550 |
Processor addTimedBlock:repeatBlock afterSeconds:dly |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
551 |
] |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
552 |
] |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
553 |
] |
76 | 554 |
] |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
555 |
|
704 | 556 |
"Modified: 28.5.1996 / 20:21:24 / cg" |
76 | 557 |
! ! |
121 | 558 |
|
559 |
!ButtonController methodsFor:'initialization'! |
|
560 |
||
561 |
initialize |
|
562 |
super initialize. |
|
563 |
||
266 | 564 |
enableChannel := true asValue. |
565 |
enableChannel onChangeSend:#enableStateChange to:self. |
|
133 | 566 |
|
121 | 567 |
active := false. |
568 |
pressed := false. |
|
569 |
entered := false. |
|
570 |
autoRepeat := false. |
|
571 |
initialDelay := self class defaultInitialDelay. |
|
572 |
repeatDelay := self class defaultRepeatDelay. |
|
573 |
isTriggerOnDown := false. |
|
574 |
isToggle := false. |
|
575 |
! ! |
|
200 | 576 |
|
203 | 577 |
!ButtonController class methodsFor:'documentation'! |
578 |
||
579 |
version |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
580 |
^ '$Header: /cvs/stx/stx/libwidg/ButtonController.st,v 1.34 1996-05-28 20:11:10 cg Exp $' |
203 | 581 |
! ! |