ToggleController.st
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--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     1
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     3
	      All Rights Reserved
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     4
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     5
 This software is furnished under a license and may be used
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     6
 only in accordance with the terms of that license and with the
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
     9
 other person.  No title to or ownership of the software is
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    10
 hereby transferred.
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    11
"
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    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
1122ab450f80 Initial revision
claus
parents:
diff changeset
    15
ButtonController subclass:#ToggleController
582
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    16
	instanceVariableNames:'action'
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    17
	classVariableNames:''
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    18
	poolDictionaries:''
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    19
	category:'Interface-Support-Controllers'
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    20
!
1122ab450f80 Initial revision
claus
parents:
diff changeset
    21
88
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    22
!ToggleController class methodsFor:'documentation'!
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    23
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    24
copyright
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    25
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    27
	      All Rights Reserved
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    28
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    29
 This software is furnished under a license and may be used
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    30
 only in accordance with the terms of that license and with the
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    32
 be provided or otherwise made available to, or used by, any
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    33
 other person.  No title to or ownership of the software is
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    34
 hereby transferred.
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    35
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    36
!
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    37
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    38
documentation
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    39
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    40
    ToggleControllers redefine some of ButtonControllers behavior;
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    41
    user interaction: they always triggerOnDown, and ignore buttonrelease.
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    42
    Finally, every buttonPress leads to a toggle action.
125
claus
parents: 120
diff changeset
    43
128
claus
parents: 126
diff changeset
    44
    ToggleController adds another actionBlock, since it inherits press-
125
claus
parents: 120
diff changeset
    45
    and releaseActions, while we want one actionBlock to be used for both
claus
parents: 120
diff changeset
    46
    on- and off. The actionBlock (if any) is evaluated with the current
claus
parents: 120
diff changeset
    47
    toggles state if it expects an argument, or without argument if its a no-arg
claus
parents: 120
diff changeset
    48
    block.
128
claus
parents: 126
diff changeset
    49
claus
parents: 126
diff changeset
    50
    Other than that, all model relations are inherited - i.e. if the view has a model,
claus
parents: 126
diff changeset
    51
    that one gets change-messages and the toggle updates on aspect changes.
582
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    52
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    53
    [author:]
e151eeae2c9a documentation
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    54
        Claus Gittinger
88
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    55
"
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    56
! !
7560534e9026 *** empty log message ***
claus
parents: 78
diff changeset
    57
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    58
!ToggleController methodsFor:'accessing'!
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    59
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    60
action:aBlock
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    61
    "set the action to be performed. This is called
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    62
     with the toggles state as argument."
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    63
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    64
    action := aBlock
119
claus
parents: 88
diff changeset
    65
! !
claus
parents: 88
diff changeset
    66
claus
parents: 88
diff changeset
    67
!ToggleController methodsFor:'events'!
claus
parents: 88
diff changeset
    68
claus
parents: 88
diff changeset
    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
claus
parents: 119
diff changeset
    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
claus
parents: 119
diff changeset
    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
1122ab450f80 Initial revision
claus
parents:
diff changeset
    84
! !
1122ab450f80 Initial revision
claus
parents:
diff changeset
    85
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    86
!ToggleController methodsFor:'initialization'!
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    87
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
initialize
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
    super initialize.
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    90
    self beToggle
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
! !
78
1122ab450f80 Initial revision
claus
parents:
diff changeset
    92
203
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    93
!ToggleController class methodsFor:'documentation'!
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    94
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    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
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    97
! !