author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 00:12:53 +0100 | |
changeset 940 | e53f681448f0 |
parent 789 | d1603717af51 |
child 971 | 8caaeb9d63fb |
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 |
789 | 16 |
pressActionBlock releaseActionBlock isToggle isRadio' |
262 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Support-Controllers' |
|
76 | 20 |
! |
21 |
||
789 | 22 |
!ButtonController class methodsFor:'documentation'! |
76 | 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 |
||
789 | 83 |
!ButtonController class methodsFor:'defaults'! |
76 | 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 |
||
789 | 134 |
beRadioButton |
135 |
"make the receiver act like a radioButton; |
|
136 |
That is like a toggle, but do not allow turning myself off |
|
137 |
by buttonPress (instead, must be turned off by another button or programmatically)" |
|
138 |
||
139 |
isTriggerOnDown := true. |
|
140 |
isToggle := false. |
|
141 |
isRadio := true. |
|
142 |
||
143 |
"Created: 15.7.1996 / 13:42:06 / cg" |
|
144 |
! |
|
145 |
||
200 | 146 |
beToggle |
147 |
"make the receiver act like a toggle" |
|
148 |
||
149 |
isTriggerOnDown := true. |
|
789 | 150 |
isToggle := true. |
151 |
isRadio := false. |
|
152 |
||
153 |
"Modified: 15.7.1996 / 13:42:15 / cg" |
|
121 | 154 |
! |
76 | 155 |
|
200 | 156 |
beTriggerOnDown |
157 |
"make the receiver act on button press" |
|
158 |
||
159 |
isTriggerOnDown := true |
|
160 |
! |
|
161 |
||
162 |
beTriggerOnUp |
|
163 |
"make the receiver act on button release" |
|
121 | 164 |
|
200 | 165 |
isTriggerOnDown := false |
166 |
! |
|
167 |
||
168 |
disable |
|
169 |
"disable the button" |
|
170 |
||
171 |
enableChannel value ifTrue:[ |
|
172 |
enableChannel value:false. |
|
173 |
"/ view redraw - not needed; I listen to enableChannel |
|
174 |
] |
|
121 | 175 |
! |
176 |
||
200 | 177 |
enable |
178 |
"enable the button" |
|
121 | 179 |
|
200 | 180 |
enableChannel value ifFalse:[ |
181 |
enableChannel value:true. |
|
182 |
"/ view redraw - not needed; I listen to enableChannel |
|
183 |
] |
|
76 | 184 |
! |
185 |
||
200 | 186 |
isTriggerOnDown |
187 |
"return true, if I trigger on press |
|
188 |
(in contrast to triggering on up, which is the default)" |
|
189 |
||
190 |
^ isTriggerOnDown |
|
191 |
! |
|
192 |
||
193 |
pressAction |
|
194 |
"return the pressAction; thats the block which gets evaluated |
|
195 |
when the button is pressed (if non-nil)" |
|
196 |
||
197 |
^ pressActionBlock |
|
198 |
! |
|
199 |
||
200 |
pressAction:aBlock |
|
201 |
"define the action to be performed on press" |
|
202 |
||
203 |
pressActionBlock := aBlock |
|
128 | 204 |
! |
205 |
||
200 | 206 |
releaseAction |
207 |
"return the releaseAction; thats the block which gets evaluated |
|
208 |
when the button is relreased (if non-nil)" |
|
209 |
||
210 |
^ releaseActionBlock |
|
211 |
! |
|
212 |
||
213 |
releaseAction:aBlock |
|
214 |
"define the action to be performed on release" |
|
215 |
||
216 |
releaseActionBlock := aBlock |
|
128 | 217 |
! |
218 |
||
200 | 219 |
triggerOnDown:aBoolean |
220 |
"set/clear the flag which controls if the action block is to be evaluated |
|
221 |
on press or on release. |
|
222 |
(see also ST-80 compatibility methods beTriggerOn*)" |
|
223 |
||
224 |
isTriggerOnDown := aBoolean |
|
128 | 225 |
! ! |
226 |
||
145 | 227 |
!ButtonController methodsFor:'accessing-channels'! |
228 |
||
229 |
enableChannel |
|
602 | 230 |
"return the valueHolder holding the enable boolean value" |
145 | 231 |
|
232 |
^ enableChannel |
|
602 | 233 |
|
234 |
"Modified: 30.4.1996 / 15:09:30 / cg" |
|
145 | 235 |
! |
236 |
||
237 |
enableChannel:aValueHolder |
|
238 |
"set the valueHolder, which holds the enable boolean value" |
|
239 |
||
162 | 240 |
|wasEnabled| |
241 |
||
145 | 242 |
enableChannel notNil ifTrue:[ |
162 | 243 |
wasEnabled := enableChannel value. |
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
220
diff
changeset
|
244 |
enableChannel retractInterestsFor:self. |
162 | 245 |
] ifFalse:[ |
246 |
wasEnabled := true |
|
145 | 247 |
]. |
248 |
enableChannel := aValueHolder. |
|
249 |
aValueHolder onChangeSend:#enableStateChange to:self. |
|
162 | 250 |
enableChannel value ~~ wasEnabled ifTrue:[ |
251 |
self enableStateChange |
|
145 | 252 |
] |
162 | 253 |
|
254 |
"Modified: 17.9.1995 / 19:41:18 / claus" |
|
145 | 255 |
! |
256 |
||
257 |
pressChannel:aChannel |
|
258 |
pressChannel := aChannel |
|
259 |
! |
|
260 |
||
261 |
releaseChannel:aChannel |
|
262 |
releaseChannel := aChannel |
|
263 |
! ! |
|
264 |
||
200 | 265 |
!ButtonController methodsFor:'accessing-state'! |
76 | 266 |
|
200 | 267 |
active |
268 |
"return true, if I am active; |
|
269 |
that is: currently performing my action. |
|
270 |
This query can be used to avoid multiple redraws." |
|
76 | 271 |
|
200 | 272 |
^ active |
128 | 273 |
! |
274 |
||
200 | 275 |
active:aBoolean |
276 |
active := aBoolean |
|
76 | 277 |
! |
278 |
||
200 | 279 |
enabled |
280 |
"return true, if I am enabled" |
|
128 | 281 |
|
200 | 282 |
^ enableChannel value |
76 | 283 |
! |
284 |
||
200 | 285 |
entered |
286 |
"return true, if the mouse pointer is currently in my view" |
|
155 | 287 |
|
200 | 288 |
^ entered |
289 |
! |
|
155 | 290 |
|
200 | 291 |
entered:aBoolean |
292 |
entered := aBoolean |
|
155 | 293 |
! |
294 |
||
200 | 295 |
pressed |
296 |
"return true, if I am pressed" |
|
76 | 297 |
|
200 | 298 |
^ pressed |
76 | 299 |
! |
300 |
||
200 | 301 |
pressed:aBoolean |
302 |
pressed ~~ aBoolean ifTrue:[ |
|
303 |
pressed := aBoolean. |
|
304 |
self performAction. |
|
118 | 305 |
]. |
306 |
! |
|
307 |
||
200 | 308 |
setPressed:aBoolean |
309 |
pressed := aBoolean. |
|
121 | 310 |
|
200 | 311 |
"Created: 14.11.1995 / 21:37:08 / cg" |
266 | 312 |
! |
313 |
||
314 |
toggle |
|
315 |
"toggle and perform the action" |
|
316 |
||
317 |
enableChannel value ifTrue:[ |
|
318 |
self toggleNoAction. |
|
319 |
self performAction. |
|
320 |
view changed:#toggle with:pressed |
|
321 |
] |
|
322 |
! |
|
323 |
||
324 |
toggleNoAction |
|
325 |
"toggle, but do NOT perform any action" |
|
326 |
||
327 |
pressed ifTrue:[ |
|
328 |
view turnOff. |
|
329 |
pressed := false. |
|
330 |
] ifFalse:[ |
|
331 |
view turnOn. |
|
332 |
pressed := true. |
|
333 |
]. |
|
76 | 334 |
! ! |
335 |
||
336 |
!ButtonController methodsFor:'event handling'! |
|
337 |
||
200 | 338 |
buttonMultiPress:button x:x y:y |
339 |
^ self buttonPress:button x:x y:y |
|
340 |
! |
|
341 |
||
76 | 342 |
buttonPress:button x:x y:y |
343 |
(button == 1 or:[button == #select]) ifFalse:[ |
|
789 | 344 |
^ super buttonPress:button x:x y:y |
76 | 345 |
]. |
346 |
||
133 | 347 |
enableChannel value ifTrue:[ |
789 | 348 |
isToggle ifTrue:[ |
349 |
self toggle. |
|
350 |
^ self |
|
351 |
]. |
|
352 |
isRadio ifTrue:[ |
|
353 |
pressed ifFalse:[ |
|
354 |
self toggle |
|
355 |
]. |
|
356 |
^ self |
|
357 |
]. |
|
118 | 358 |
|
789 | 359 |
pressed ifFalse:[ |
360 |
pressed := true. |
|
361 |
view showActive. |
|
76 | 362 |
|
789 | 363 |
(pressActionBlock notNil or:[model notNil]) ifTrue:[ |
364 |
" |
|
365 |
force output - so that button is drawn correctly in case |
|
366 |
of any long-computation (at high priority) |
|
367 |
" |
|
368 |
view flush. |
|
369 |
]. |
|
76 | 370 |
|
789 | 371 |
self performAction. |
76 | 372 |
|
789 | 373 |
autoRepeat ifTrue:[ |
374 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
|
375 |
] |
|
376 |
] |
|
76 | 377 |
] |
262 | 378 |
|
789 | 379 |
"Modified: 15.7.1996 / 14:07:48 / cg" |
76 | 380 |
! |
381 |
||
382 |
buttonRelease:button x:x y:y |
|
383 |
"button was released - if enabled, perform releaseaction" |
|
384 |
||
385 |
(button == 1 or:[button == #select]) ifFalse:[ |
|
789 | 386 |
^ super buttonRelease:button x:x y:y |
76 | 387 |
]. |
118 | 388 |
|
789 | 389 |
(isToggle or:[isRadio]) ifTrue:[ |
390 |
^ self |
|
118 | 391 |
]. |
392 |
||
76 | 393 |
pressed ifTrue:[ |
789 | 394 |
autoRepeat ifTrue:[ |
395 |
Processor removeTimedBlock:repeatBlock |
|
396 |
]. |
|
397 |
pressed := false. |
|
398 |
view showPassive. |
|
76 | 399 |
|
789 | 400 |
enableChannel value ifTrue:[ |
401 |
" |
|
402 |
only perform action if released within myself |
|
403 |
" |
|
404 |
((x >= 0) |
|
405 |
and:[x <= view width |
|
406 |
and:[y >= 0 |
|
407 |
and:[y <= view height]]]) ifTrue:[ |
|
408 |
(releaseActionBlock notNil or:[model notNil]) ifTrue:[ |
|
409 |
" |
|
410 |
force output - so that button is drawn correctly in case |
|
411 |
of any long-computation (at high priority) |
|
412 |
" |
|
413 |
view flush. |
|
414 |
]. |
|
76 | 415 |
|
789 | 416 |
self performAction. |
417 |
] |
|
418 |
] |
|
76 | 419 |
] |
262 | 420 |
|
789 | 421 |
"Modified: 15.7.1996 / 13:42:34 / cg" |
76 | 422 |
! |
423 |
||
200 | 424 |
enableStateChange |
425 |
"this is sent, whenever the enable value has changed" |
|
76 | 426 |
|
200 | 427 |
view notNil ifTrue:[view enableStateChangeRedraw] |
428 |
||
429 |
"Modified: 17.9.1995 / 19:55:52 / claus" |
|
76 | 430 |
! |
431 |
||
200 | 432 |
keyPress:key x:x y:y |
433 |
"trigger on Return and space, if I am the focusView of my group |
|
434 |
(i.e. if I got an explicit focus)" |
|
121 | 435 |
|
349
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
436 |
key == Character space ifTrue:[ |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
437 |
view hasFocus ifTrue:[ |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
438 |
"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
|
439 |
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
|
440 |
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
|
441 |
^ self. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
442 |
] |
200 | 443 |
]. |
444 |
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
|
445 |
|
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
446 |
"Modified: 9.2.1996 / 23:11:58 / cg" |
121 | 447 |
! |
448 |
||
449 |
performAction |
|
146 | 450 |
|action value| |
133 | 451 |
|
789 | 452 |
(isToggle or:[isRadio]) ifTrue:[ |
453 |
value := pressed |
|
133 | 454 |
] ifFalse:[ |
789 | 455 |
value := true |
133 | 456 |
]. |
76 | 457 |
|
125 | 458 |
" |
145 | 459 |
ST/X style actionBlock evaluation & channel notification ... |
125 | 460 |
" |
76 | 461 |
pressed ifTrue:[ |
789 | 462 |
action := pressActionBlock. |
121 | 463 |
] ifFalse:[ |
789 | 464 |
action := releaseActionBlock. |
121 | 465 |
]. |
125 | 466 |
action notNil ifTrue:[ |
789 | 467 |
active := true. |
468 |
action numArgs == 0 ifTrue:[ |
|
469 |
action value |
|
470 |
] ifFalse:[ |
|
471 |
action value:value |
|
472 |
]. |
|
473 |
active := false. |
|
125 | 474 |
]. |
146 | 475 |
pressChannel notNil ifTrue:[ |
789 | 476 |
pressChannel value:pressed |
146 | 477 |
]. |
478 |
releaseChannel notNil ifTrue:[ |
|
789 | 479 |
releaseChannel value:pressed not |
145 | 480 |
]. |
76 | 481 |
|
125 | 482 |
" |
483 |
ST-80 style model notification ... |
|
484 |
" |
|
121 | 485 |
(isToggle |
486 |
or:[(isTriggerOnDown and:[pressed]) |
|
487 |
or:[isTriggerOnDown not and:[pressed not]]]) ifTrue:[ |
|
789 | 488 |
"the ST-80 way of doing things" |
489 |
view notNil ifTrue:[ |
|
490 |
active := true. |
|
491 |
view sendChangeMessageWith:value. |
|
492 |
active := false. |
|
493 |
]. |
|
121 | 494 |
]. |
789 | 495 |
|
496 |
"Modified: 15.7.1996 / 13:40:59 / cg" |
|
76 | 497 |
! |
498 |
||
200 | 499 |
pointerEnter:state x:x y:y |
500 |
"mouse pointer entered my view. |
|
501 |
Redraw with enteredColors if they differ from the normal colors" |
|
502 |
||
503 |
entered := true. |
|
504 |
enableChannel value ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
505 |
pressed ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
506 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
507 |
reentered after a leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
508 |
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
|
509 |
triggerOnDown, show active again. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
510 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
511 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
512 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
513 |
]. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
514 |
isTriggerOnDown ifFalse:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
515 |
view showActive. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
516 |
] |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
517 |
] ifFalse:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
518 |
view invalidate |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
519 |
] |
200 | 520 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
521 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
522 |
"Modified: 26.5.1996 / 18:09:06 / cg" |
76 | 523 |
! |
524 |
||
200 | 525 |
pointerLeave:state |
526 |
"mouse pointer left my view. |
|
527 |
Redraw with normal colors if they differ from enteredColors" |
|
76 | 528 |
|
200 | 529 |
entered := false. |
530 |
pressed ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
531 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
532 |
leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
533 |
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
|
534 |
action on release, show passive |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
535 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
536 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
537 |
Processor removeTimedBlock:repeatBlock |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
538 |
]. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
539 |
isTriggerOnDown ifFalse:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
540 |
view showPassive. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
541 |
] |
200 | 542 |
] ifFalse:[ |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
543 |
enableChannel value ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
544 |
view invalidate |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
545 |
] |
200 | 546 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
547 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
548 |
"Modified: 26.5.1996 / 18:09:08 / cg" |
76 | 549 |
! |
550 |
||
121 | 551 |
repeat |
552 |
"this is sent from the autorepeat-block, when the button has been pressed long |
|
553 |
enough; it simulates a release-press, by evaluating both release |
|
554 |
and press actions." |
|
76 | 555 |
|
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
556 |
|dly| |
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
557 |
|
76 | 558 |
pressed ifTrue:[ |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
559 |
enableChannel value ifTrue:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
560 |
active ifFalse:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
561 |
self performAction. |
155 | 562 |
"/ active := true. |
563 |
"/ releaseActionBlock notNil ifTrue:[releaseActionBlock value]. |
|
564 |
"/ pressActionBlock notNil ifTrue:[pressActionBlock value]. |
|
565 |
"/ active := false. |
|
121 | 566 |
|
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
567 |
autoRepeat ifTrue:[ |
704 | 568 |
view graphicsDevice shiftDown ifTrue:[ |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
569 |
dly := repeatDelay / 4. |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
570 |
] ifFalse:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
571 |
dly := repeatDelay |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
572 |
]. |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
573 |
Processor addTimedBlock:repeatBlock afterSeconds:dly |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
574 |
] |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
575 |
] |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
576 |
] |
76 | 577 |
] |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
578 |
|
704 | 579 |
"Modified: 28.5.1996 / 20:21:24 / cg" |
76 | 580 |
! ! |
121 | 581 |
|
582 |
!ButtonController methodsFor:'initialization'! |
|
583 |
||
584 |
initialize |
|
585 |
super initialize. |
|
586 |
||
266 | 587 |
enableChannel := true asValue. |
588 |
enableChannel onChangeSend:#enableStateChange to:self. |
|
133 | 589 |
|
121 | 590 |
active := false. |
591 |
pressed := false. |
|
592 |
entered := false. |
|
593 |
autoRepeat := false. |
|
594 |
initialDelay := self class defaultInitialDelay. |
|
595 |
repeatDelay := self class defaultRepeatDelay. |
|
596 |
isTriggerOnDown := false. |
|
789 | 597 |
isToggle := isRadio := false. |
598 |
||
599 |
"Modified: 15.7.1996 / 13:40:14 / cg" |
|
121 | 600 |
! ! |
200 | 601 |
|
789 | 602 |
!ButtonController class methodsFor:'documentation'! |
203 | 603 |
|
604 |
version |
|
789 | 605 |
^ '$Header: /cvs/stx/stx/libwidg/Attic/ButtonC.st,v 1.35 1996-07-15 14:41:08 cg Exp $' |
203 | 606 |
! ! |