author | Claus Gittinger <cg@exept.de> |
Sat, 20 Jun 2009 10:47:07 +0200 | |
changeset 3901 | 113dd960ba11 |
parent 2504 | f12dab112227 |
child 4524 | 0a8e4c9060ae |
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 |
|
2504
f12dab112227
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
973
diff
changeset
|
13 |
"{ Package: 'stx:libwidg' }" |
f12dab112227
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
973
diff
changeset
|
14 |
|
78 | 15 |
ButtonController subclass:#ToggleController |
582 | 16 |
instanceVariableNames:'action' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Support-Controllers' |
|
78 | 20 |
! |
21 |
||
88 | 22 |
!ToggleController 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 |
ToggleControllers redefine some of ButtonControllers behavior; |
|
41 |
user interaction: they always triggerOnDown, and ignore buttonrelease. |
|
42 |
Finally, every buttonPress leads to a toggle action. |
|
125 | 43 |
|
128 | 44 |
ToggleController adds another actionBlock, since it inherits press- |
125 | 45 |
and releaseActions, while we want one actionBlock to be used for both |
46 |
on- and off. The actionBlock (if any) is evaluated with the current |
|
47 |
toggles state if it expects an argument, or without argument if its a no-arg |
|
48 |
block. |
|
128 | 49 |
|
50 |
Other than that, all model relations are inherited - i.e. if the view has a model, |
|
51 |
that one gets change-messages and the toggle updates on aspect changes. |
|
582 | 52 |
|
53 |
[author:] |
|
54 |
Claus Gittinger |
|
88 | 55 |
" |
56 |
! ! |
|
57 |
||
200 | 58 |
!ToggleController methodsFor:'accessing'! |
78 | 59 |
|
200 | 60 |
action:aBlock |
61 |
"set the action to be performed. This is called |
|
62 |
with the toggles state as argument." |
|
63 |
||
64 |
action := aBlock |
|
119 | 65 |
! ! |
66 |
||
67 |
!ToggleController methodsFor:'events'! |
|
68 |
||
69 |
performAction |
|
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
70 |
"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
|
71 |
channels, then evaluate any (optional) press/release actions, |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
72 |
finally evaluate my real action, the toggle action. |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
73 |
Individual press/release actions are usually nil for toggles." |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
74 |
|
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
75 |
super performAction. |
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
76 |
|
120 | 77 |
action notNil ifTrue:[ |
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
78 |
active := true. |
2504
f12dab112227
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
973
diff
changeset
|
79 |
action valueWithOptionalArgument:pressed. |
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
80 |
active := false. |
120 | 81 |
]. |
973
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
82 |
|
bcc8b920dccc
model notifications first - then actionBlocks.
Claus Gittinger <cg@exept.de>
parents:
582
diff
changeset
|
83 |
"Modified: 24.1.1997 / 15:42:14 / cg" |
78 | 84 |
! ! |
85 |
||
200 | 86 |
!ToggleController methodsFor:'initialization'! |
78 | 87 |
|
200 | 88 |
initialize |
89 |
super initialize. |
|
90 |
self beToggle |
|
91 |
! ! |
|
78 | 92 |
|
203 | 93 |
!ToggleController class methodsFor:'documentation'! |
94 |
||
95 |
version |
|
2504
f12dab112227
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
973
diff
changeset
|
96 |
^ '$Header: /cvs/stx/stx/libwidg/ToggleController.st,v 1.13 2001-12-14 10:57:30 cg Exp $' |
203 | 97 |
! ! |