68 |
68 |
69 [author:] |
69 [author:] |
70 Claus Gittinger |
70 Claus Gittinger |
71 |
71 |
72 [see also:] |
72 [see also:] |
73 CheckBox RadioButton RadioButtonGroup Toggle Button |
73 CheckBox RadioButton RadioButtonGroup Toggle Button |
|
74 Dialog |
|
75 ValueHolder TriggerValue |
|
76 Block |
74 " |
77 " |
75 ! |
78 ! |
76 |
79 |
77 examples |
80 examples |
78 " |
81 " |
79 checkToggle alone: |
82 checkToggle alone: |
80 |
83 [exBegin] |
81 |top check| |
84 |top check| |
82 |
85 |
83 top := StandardSystemView new. |
86 top := StandardSystemView new. |
84 top extent:100@100. |
87 top extent:100@100. |
85 |
88 |
86 check := CheckToggle in:top. |
89 check := CheckToggle in:top. |
87 check origin:10@10. |
90 check origin:10@10. |
88 |
91 |
89 top open |
92 top open |
|
93 [exEnd] |
|
94 |
90 |
95 |
91 give it an action: |
96 give it an action: |
92 |
97 [exBegin] |
93 |top check| |
98 |top check| |
94 |
99 |
95 top := StandardSystemView new. |
100 top := StandardSystemView new. |
96 top extent:100@100. |
101 top extent:100@100. |
97 |
102 |
98 check := CheckToggle in:top. |
103 check := CheckToggle in:top. |
99 check origin:10@10. |
104 check origin:10@10. |
100 check action:[:value | Transcript showCr:'changed to: ' , value printString]. |
105 check action:[:value | Transcript showCr:'changed to: ' , value printString]. |
101 |
106 |
102 top open |
107 top open |
|
108 [exEnd] |
|
109 |
103 |
110 |
104 give it a model: |
111 give it a model: |
105 |
112 [exBegin] |
106 |top check model| |
113 |top check model| |
107 |
114 |
108 model := false asValue. |
115 model := false asValue. |
109 |
116 |
110 top := StandardSystemView new. |
117 top := StandardSystemView new. |
111 top extent:100@100. |
118 top extent:100@100. |
112 |
119 |
113 check := CheckToggle in:top. |
120 check := CheckToggle in:top. |
114 check origin:10@10. |
121 check origin:10@10. |
115 check model:model. |
122 check model:model. |
116 |
123 |
117 top openModal. |
124 top openModal. |
118 |
125 |
119 Transcript showCr:'value after closing box: ' , model value printString |
126 Transcript showCr:'value after closing box: ' , model value printString |
|
127 [exEnd] |
|
128 |
120 |
129 |
121 multiple checks on a single model (with different change selectors): |
130 multiple checks on a single model (with different change selectors): |
122 (using a checkBox here, for the demonstration ...) |
131 (using a checkBox here, for the demonstration ...) |
123 (this is a typical many-in-many setup) |
132 (this is a typical many-in-many setup) |
124 |
133 [exBegin] |
125 |top model panel ext1 ext2 |
134 |top model panel ext1 ext2 |
126 readFlag writeFlag executeFlag| |
135 readFlag writeFlag executeFlag| |
127 |
136 |
128 readFlag := writeFlag := true. |
137 readFlag := writeFlag := true. |
129 executeFlag := false. |
138 executeFlag := false. |
130 |
139 |
131 model := Plug new. |
140 model := Plug new. |
132 model respondTo:#read with:[readFlag]. |
141 model respondTo:#read with:[readFlag]. |
133 model respondTo:#write with:[writeFlag]. |
142 model respondTo:#write with:[writeFlag]. |
134 model respondTo:#execute with:[executeFlag]. |
143 model respondTo:#execute with:[executeFlag]. |
135 model respondTo:#read: with:[:val | readFlag := val]. |
144 model respondTo:#read: with:[:val | readFlag := val]. |
136 model respondTo:#write: with:[:val | writeFlag := val]. |
145 model respondTo:#write: with:[:val | writeFlag := val]. |
137 model respondTo:#execute: with:[:val | executeFlag := val]. |
146 model respondTo:#execute: with:[:val | executeFlag := val]. |
138 |
147 |
139 top := StandardSystemView new. |
148 top := StandardSystemView new. |
140 top extent:200@200. |
149 top extent:200@200. |
141 top label:'File permissions:'. |
150 top label:'File permissions:'. |
142 |
151 |
143 panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
152 panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
144 |
153 panel horizontalLayout:#leftSpace. |
145 #(read write execute) do:[:sym | |
154 |
146 |check| |
155 #(read write execute) do:[:sym | |
147 |
156 |check| |
148 check := CheckBox in:panel. |
157 |
149 check label:sym. |
158 check := CheckBox in:panel. |
150 check model:model; aspect:sym; changeMessage:(sym , ':') asSymbol. |
159 check label:sym. |
151 ]. |
160 check model:model; aspect:sym; changeMessage:(sym , ':') asSymbol. |
152 |
161 ]. |
153 top openModal. |
162 |
154 |
163 top openModal. |
155 Transcript showCr:'settings after closing box:'. |
164 |
156 Transcript showCr:' read -> ' , readFlag printString. |
165 Transcript showCr:'settings after closing box:'. |
157 Transcript showCr:' write -> ' , writeFlag printString. |
166 Transcript showCr:' read -> ' , readFlag printString. |
158 Transcript showCr:' execute -> ' , executeFlag printString. |
167 Transcript showCr:' write -> ' , writeFlag printString. |
159 |
168 Transcript showCr:' execute -> ' , executeFlag printString. |
160 |
169 [exEnd] |
161 checkToggles in a group |
170 |
|
171 |
|
172 checkToggles in a group - now, they have RadioButton behavior. |
162 (this is a typical one-in-many setup) |
173 (this is a typical one-in-many setup) |
163 |
174 [exBegin] |
164 |top panel check1 check2 check3 grp| |
175 |top panel check1 check2 check3 grp| |
165 |
176 |
166 top := StandardSystemView new. |
177 top := StandardSystemView new. |
167 top extent:200@300. |
178 top extent:200@300. |
168 |
179 |
169 panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
180 panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
170 |
181 |
171 check1 := CheckToggle in:panel. |
182 check1 := CheckToggle in:panel. |
172 check2 := CheckToggle in:panel. |
183 check2 := CheckToggle in:panel. |
173 check3 := CheckToggle in:panel. |
184 check3 := CheckToggle in:panel. |
174 |
185 |
175 grp := RadioButtonGroup new. |
186 grp := RadioButtonGroup new. |
176 grp add:check1. |
187 grp add:check1. |
177 grp add:check2. |
188 grp add:check2. |
178 grp add:check3. |
189 grp add:check3. |
179 |
190 |
180 top open |
191 top open |
|
192 [exEnd] |
181 |
193 |
182 |
194 |
183 Channel operation |
195 Channel operation |
184 ----------------- |
196 ----------------- |
185 |
197 |
186 enabling other toggles via a toggle |
198 enabling other toggles via a toggle |
187 |
199 [exBegin] |
188 |top panel t enableChannel| |
200 |top panel t enableChannel| |
189 |
201 |
190 top := StandardSystemView new. |
202 top := StandardSystemView new. |
191 top extent:(400 @ 200). |
203 top extent:(400 @ 200). |
192 |
204 |
193 panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
205 panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
194 |
206 |
195 enableChannel := false asValue. |
207 enableChannel := false asValue. |
196 |
208 |
197 1 to:10 do:[:i | |
209 1 to:10 do:[:i | |
198 t := CheckToggle in:panel. |
210 t := CheckToggle in:panel. |
199 t enableChannel:enableChannel. |
211 t enableChannel:enableChannel. |
200 ]. |
212 ]. |
201 |
213 |
202 t := Toggle in:panel. |
214 t := Toggle in:panel. |
203 t activeLogo:'enabled'; passiveLogo:'disabled'. |
215 t activeLogo:'enabled'; passiveLogo:'disabled'. |
204 t controller pressChannel:enableChannel. |
216 t pressChannel:enableChannel. |
205 |
217 |
206 top open |
218 top open |
|
219 [exEnd] |
207 " |
220 " |
208 ! ! |
221 ! ! |
209 |
222 |
210 !CheckToggle class methodsFor:'defaults'! |
223 !CheckToggle class methodsFor:'defaults'! |
211 |
224 |