4393
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2013 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 |
"
|
|
12 |
"{ Package: 'stx:libwidg2' }"
|
|
13 |
|
|
14 |
CheckBox subclass:#TriggerBox
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Views-Interactors'
|
|
19 |
!
|
|
20 |
|
|
21 |
!TriggerBox class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2013 by Claus Gittinger
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
|
37 |
documentation
|
|
38 |
"
|
|
39 |
A TriggerBox looks similar to a CheckBox (it contains a button and a label),
|
|
40 |
but does not show a check-icon.
|
|
41 |
Instead, a trigger button (unlabelled) performs a momentary action when pressed.
|
|
42 |
"
|
|
43 |
!
|
|
44 |
|
|
45 |
examples
|
|
46 |
"
|
|
47 |
no-op TriggerBox without a label:
|
|
48 |
[exBegin]
|
|
49 |
|b|
|
|
50 |
|
|
51 |
b := TriggerBox new.
|
|
52 |
b open
|
|
53 |
[exEnd]
|
|
54 |
|
|
55 |
|
|
56 |
no-op TriggerBox:
|
|
57 |
[exBegin]
|
|
58 |
|b|
|
|
59 |
|
|
60 |
b := TriggerBox new.
|
|
61 |
b label:'foo'.
|
|
62 |
b open
|
|
63 |
[exEnd]
|
|
64 |
|
|
65 |
|
|
66 |
combined instance creation & label setup:
|
|
67 |
[exBegin]
|
|
68 |
|b|
|
|
69 |
|
|
70 |
b := TriggerBox label:'foo'.
|
|
71 |
b open
|
|
72 |
[exEnd]
|
|
73 |
|
|
74 |
|
|
75 |
no-op trigger, disabled:
|
|
76 |
[exBegin]
|
|
77 |
|b|
|
|
78 |
|
|
79 |
b := TriggerBox label:'foo'.
|
|
80 |
b disable.
|
|
81 |
b open
|
|
82 |
[exEnd]
|
|
83 |
|
|
84 |
|
4406
|
85 |
using a trigger channel instead of a callback:
|
|
86 |
[exBegin]
|
|
87 |
|b holder|
|
|
88 |
|
|
89 |
holder := TriggerValue new.
|
|
90 |
holder onChangeEvaluate:[ Transcript showCR:'changed'].
|
|
91 |
b := TriggerBox label:'foo'.
|
|
92 |
b triggerChannel:holder.
|
|
93 |
b open
|
|
94 |
[exEnd]
|
|
95 |
|
|
96 |
|
4393
|
97 |
changing colors
|
|
98 |
[exBegin]
|
|
99 |
|panel b|
|
|
100 |
|
|
101 |
panel := VerticalPanelView new.
|
|
102 |
|
|
103 |
b := TriggerBox label:'foo' in:panel.
|
|
104 |
|
|
105 |
b := TriggerBox label:'bar' in:panel.
|
|
106 |
b labelView foregroundColor:Color red.
|
|
107 |
|
|
108 |
b := TriggerBox label:'baz' in:panel.
|
|
109 |
b toggleView activeForegroundColor:Color blue.
|
|
110 |
|
|
111 |
panel open
|
|
112 |
[exEnd]
|
|
113 |
|
|
114 |
|
|
115 |
using action-blocks:
|
|
116 |
[exBegin]
|
|
117 |
|b|
|
|
118 |
|
|
119 |
b := TriggerBox label:'check'.
|
|
120 |
b action:[:value | Transcript show:'trigger called: '].
|
|
121 |
b open.
|
|
122 |
[exEnd]
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
with an enableChannel
|
|
128 |
[exBegin]
|
|
129 |
|b enaToggle enaHolder|
|
|
130 |
|
|
131 |
enaHolder := true asValue.
|
|
132 |
|
|
133 |
enaToggle := Toggle label:'enable'.
|
|
134 |
enaToggle model:enaHolder.
|
|
135 |
enaToggle open.
|
|
136 |
|
|
137 |
b := TriggerBox label:'check'.
|
|
138 |
b action:[:value | Transcript showCR:'triggered'].
|
|
139 |
b enableChannel:enaHolder.
|
|
140 |
b open.
|
|
141 |
[exEnd]
|
|
142 |
"
|
|
143 |
! !
|
|
144 |
|
4406
|
145 |
!TriggerBox methodsFor:'accessing - model'!
|
|
146 |
|
|
147 |
triggerChannel:aValueHolder
|
|
148 |
toggleView controller pressChannel:aValueHolder.
|
|
149 |
! !
|
|
150 |
|
4393
|
151 |
!TriggerBox methodsFor:'initialization & release'!
|
|
152 |
|
|
153 |
defaultCheckToggleClass
|
|
154 |
^ Toggle "/ Button
|
|
155 |
!
|
|
156 |
|
|
157 |
defaultControllerClass
|
|
158 |
^ ButtonController
|
|
159 |
!
|
|
160 |
|
|
161 |
initialize
|
|
162 |
super initialize.
|
|
163 |
toggleView extent:16@16.
|
|
164 |
|
|
165 |
toggleView activeLogo:nil.
|
|
166 |
toggleView passiveLogo:nil.
|
|
167 |
toggleView activeLevel:-2.
|
|
168 |
toggleView passiveLevel:2.
|
|
169 |
toggleView extent:10@10.
|
|
170 |
toggleView sizeFixed:true.
|
|
171 |
|
|
172 |
toggleView controller:(ButtonController new).
|
|
173 |
! !
|
|
174 |
|
|
175 |
!TriggerBox class methodsFor:'documentation'!
|
|
176 |
|
|
177 |
version
|
4406
|
178 |
^ '$Header: /cvs/stx/stx/libwidg2/TriggerBox.st,v 1.2 2013-09-19 11:47:48 cg Exp $'
|
4393
|
179 |
!
|
|
180 |
|
|
181 |
version_CVS
|
4406
|
182 |
^ '$Header: /cvs/stx/stx/libwidg2/TriggerBox.st,v 1.2 2013-09-19 11:47:48 cg Exp $'
|
4393
|
183 |
! !
|
|
184 |
|