author | tz |
Fri, 03 Apr 1998 16:54:44 +0200 | |
changeset 1477 | 2d4b6115e2c5 |
parent 973 | bcc8b920dccc |
child 2504 | f12dab112227 |
permissions | -rw-r--r-- |
88 | 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 |
" |
|
78 | 12 |
|
13 |
ButtonController subclass:#ToggleController |
|
582 | 14 |
instanceVariableNames:'action' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-Support-Controllers' |
|
78 | 18 |
! |
19 |
||
88 | 20 |
!ToggleController class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
ToggleControllers redefine some of ButtonControllers behavior; |
|
39 |
user interaction: they always triggerOnDown, and ignore buttonrelease. |
|
40 |
Finally, every buttonPress leads to a toggle action. |
|
125 | 41 |
|
128 | 42 |
ToggleController adds another actionBlock, since it inherits press- |
125 | 43 |
and releaseActions, while we want one actionBlock to be used for both |
44 |
on- and off. The actionBlock (if any) is evaluated with the current |
|
45 |
toggles state if it expects an argument, or without argument if its a no-arg |
|
46 |
block. |
|
128 | 47 |
|
48 |
Other than that, all model relations are inherited - i.e. if the view has a model, |
|
49 |
that one gets change-messages and the toggle updates on aspect changes. |
|
582 | 50 |
|
51 |
[author:] |
|
52 |
Claus Gittinger |
|
88 | 53 |
" |
54 |
! ! |
|
55 |
||
200 | 56 |
!ToggleController methodsFor:'accessing'! |
78 | 57 |
|
200 | 58 |
action:aBlock |
59 |
"set the action to be performed. This is called |
|
60 |
with the toggles state as argument." |
|
61 |
||
62 |
action := aBlock |
|
119 | 63 |
! ! |
64 |
||
65 |
!ToggleController methodsFor:'events'! |
|
66 |
||
67 |
performAction |
|
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
68 |
"the toggle changed its state; first tell the model and |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
69 |
channels, then evaluate any (optional) press/release actions, |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
70 |
finally evaluate my real action, the toggle action. |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
71 |
Individual press/release actions are usually nil for toggles." |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
72 |
|
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
73 |
super performAction. |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
74 |
|
120 | 75 |
action notNil ifTrue:[ |
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
76 |
active := true. |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
77 |
action numArgs == 0 ifTrue:[ |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
78 |
action value |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
79 |
] ifFalse:[ |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
80 |
action value:pressed |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
81 |
]. |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
82 |
active := false. |
120 | 83 |
]. |
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
84 |
|
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
85 |
"Modified: 24.1.1997 / 15:42:14 / cg" |
78 | 86 |
! ! |
87 |
||
200 | 88 |
!ToggleController methodsFor:'initialization'! |
78 | 89 |
|
200 | 90 |
initialize |
91 |
super initialize. |
|
92 |
self beToggle |
|
93 |
! ! |
|
78 | 94 |
|
203 | 95 |
!ToggleController class methodsFor:'documentation'! |
96 |
||
97 |
version |
|
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
98 |
^ '$Header: /cvs/stx/stx/libwidg/ToggleController.st,v 1.12 1997-01-24 14:42:55 cg Exp $' |
203 | 99 |
! ! |