ToggleC.st
changeset 125 3ffa271732f7
parent 120 710d41f17b68
child 126 40228f4fd66b
equal deleted inserted replaced
124:7abd3a234296 125:3ffa271732f7
    33 "
    33 "
    34 !
    34 !
    35 
    35 
    36 version
    36 version
    37 "
    37 "
    38 $Header: /cvs/stx/stx/libwidg/Attic/ToggleC.st,v 1.4 1995-05-03 16:30:51 claus Exp $
    38 $Header: /cvs/stx/stx/libwidg/Attic/ToggleC.st,v 1.5 1995-05-09 01:56:56 claus Exp $
    39 "
    39 "
    40 !
    40 !
    41 
    41 
    42 documentation
    42 documentation
    43 "
    43 "
    44     ToggleControllers redefine some of ButtonControllers behavior;
    44     ToggleControllers redefine some of ButtonControllers behavior;
    45     user interaction: they always triggerOnDown, and ignore buttonrelease.
    45     user interaction: they always triggerOnDown, and ignore buttonrelease.
    46     Finally, every buttonPress leads to a toggle action.
    46     Finally, every buttonPress leads to a toggle action.
       
    47 
       
    48     ToggleController redefines the actionBlock, since it inherits press-
       
    49     and releaseActions, while we want one actionBlock to be used for both
       
    50     on- and off. The actionBlock (if any) is evaluated with the current
       
    51     toggles state if it expects an argument, or without argument if its a no-arg
       
    52     block.
    47 "
    53 "
    48 ! !
    54 ! !
    49 
    55 
    50 !ToggleController methodsFor:'initialization'!
    56 !ToggleController methodsFor:'initialization'!
    51 
    57 
    56 
    62 
    57 !ToggleController methodsFor:'events'!
    63 !ToggleController methodsFor:'events'!
    58 
    64 
    59 performAction
    65 performAction
    60     action notNil ifTrue:[
    66     action notNil ifTrue:[
       
    67 	active := true.
    61 	action numArgs == 0 ifTrue:[
    68 	action numArgs == 0 ifTrue:[
    62 	    action value
    69 	    action value
    63 	] ifFalse:[
    70 	] ifFalse:[
    64 	    action value:pressed
    71 	    action value:pressed
    65 	].
    72 	].
       
    73 	active := false.
    66     ].
    74     ].
    67     super performAction
    75     super performAction
    68 ! !
    76 ! !
    69 
    77 
    70 !ToggleController methodsFor:'accessing'!
    78 !ToggleController methodsFor:'accessing'!
    73     "set the action to be performed. This is called
    81     "set the action to be performed. This is called
    74      with the toggles state as argument."
    82      with the toggles state as argument."
    75 
    83 
    76     action := aBlock
    84     action := aBlock
    77 ! !
    85 ! !
    78