author | Claus Gittinger <cg@exept.de> |
Thu, 23 Nov 1995 03:26:58 +0100 | |
changeset 197 | 00927189c882 |
parent 174 | d80a6cc3f9b2 |
child 200 | aa3e56929a5a |
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 |
|
119 | 14 |
instanceVariableNames:'action' |
78 | 15 |
classVariableNames:'' |
16 |
poolDictionaries:'' |
|
126 | 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 |
version |
|
174
d80a6cc3f9b2
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
128
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libwidg/ToggleController.st,v 1.8 1995-11-11 16:23:28 cg Exp $' |
88 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
ToggleControllers redefine some of ButtonControllers behavior; |
|
43 |
user interaction: they always triggerOnDown, and ignore buttonrelease. |
|
44 |
Finally, every buttonPress leads to a toggle action. |
|
125 | 45 |
|
128 | 46 |
ToggleController adds another actionBlock, since it inherits press- |
125 | 47 |
and releaseActions, while we want one actionBlock to be used for both |
48 |
on- and off. The actionBlock (if any) is evaluated with the current |
|
49 |
toggles state if it expects an argument, or without argument if its a no-arg |
|
50 |
block. |
|
128 | 51 |
|
52 |
Other than that, all model relations are inherited - i.e. if the view has a model, |
|
53 |
that one gets change-messages and the toggle updates on aspect changes. |
|
88 | 54 |
" |
55 |
! ! |
|
56 |
||
119 | 57 |
!ToggleController methodsFor:'initialization'! |
78 | 58 |
|
59 |
initialize |
|
60 |
super initialize. |
|
119 | 61 |
self beToggle |
62 |
! ! |
|
63 |
||
64 |
!ToggleController methodsFor:'events'! |
|
65 |
||
66 |
performAction |
|
120 | 67 |
action notNil ifTrue:[ |
125 | 68 |
active := true. |
120 | 69 |
action numArgs == 0 ifTrue:[ |
70 |
action value |
|
71 |
] ifFalse:[ |
|
72 |
action value:pressed |
|
73 |
]. |
|
125 | 74 |
active := false. |
120 | 75 |
]. |
119 | 76 |
super performAction |
78 | 77 |
! ! |
78 |
||
119 | 79 |
!ToggleController methodsFor:'accessing'! |
78 | 80 |
|
119 | 81 |
action:aBlock |
82 |
"set the action to be performed. This is called |
|
83 |
with the toggles state as argument." |
|
78 | 84 |
|
119 | 85 |
action := aBlock |
78 | 86 |
! ! |