.
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
ButtonController subclass:#ToggleController
instanceVariableNames:'action'
classVariableNames:''
poolDictionaries:''
category:'Interface-Support-Controllers'
!
!ToggleController class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
version
"
$Header: /cvs/stx/stx/libwidg/Attic/ToggleC.st,v 1.6 1995-05-10 02:30:25 claus Exp $
"
!
documentation
"
ToggleControllers redefine some of ButtonControllers behavior;
user interaction: they always triggerOnDown, and ignore buttonrelease.
Finally, every buttonPress leads to a toggle action.
ToggleController redefines the actionBlock, since it inherits press-
and releaseActions, while we want one actionBlock to be used for both
on- and off. The actionBlock (if any) is evaluated with the current
toggles state if it expects an argument, or without argument if its a no-arg
block.
"
! !
!ToggleController methodsFor:'initialization'!
initialize
super initialize.
self beToggle
! !
!ToggleController methodsFor:'events'!
performAction
action notNil ifTrue:[
active := true.
action numArgs == 0 ifTrue:[
action value
] ifFalse:[
action value:pressed
].
active := false.
].
super performAction
! !
!ToggleController methodsFor:'accessing'!
action:aBlock
"set the action to be performed. This is called
with the toggles state as argument."
action := aBlock
! !