-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
SpRadioButtonExample.class.st
81 lines (67 loc) · 1.66 KB
/
SpRadioButtonExample.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"
I am a demo to show how to use radio buttons with Spec.
self example
"
Class {
#name : #SpRadioButtonExample,
#superclass : #SpPresenter,
#instVars : [
'button1',
'button2',
'button3',
'label'
],
#category : #'Spec2-Examples-Demo-Checkboxes'
}
{ #category : #specs }
SpRadioButtonExample class >> defaultSpec [
^ SpBoxLayout newVertical
add: (SpBoxLayout newVertical
add: #button1 expand: false;
add: #button2 expand: false;
add: #button3 expand: false;
yourself);
add: #label expand: false;
yourself
]
{ #category : #example }
SpRadioButtonExample class >> example [
^ self new openWithSpec
]
{ #category : #specs }
SpRadioButtonExample class >> title [
^ 'Radio Button Example'
]
{ #category : #initialization }
SpRadioButtonExample >> connectPresenters [
button1 whenActivatedDo: [ self updateLabel ].
button1 whenDeactivatedDo: [ self updateLabel ].
button2 whenChangedDo: [ self updateLabel ].
button3 whenChangedDo: [ self updateLabel ]
]
{ #category : #initialization }
SpRadioButtonExample >> initializePresenters [
button1 := self newRadioButton.
button2 := self newRadioButton.
button3 := self newRadioButton.
label := self newLabel.
button1 associatedRadioButtons: { button2. button3 }.
button1 label: 'Button 1'.
button2 label: 'Button 2'.
button3 label: 'Button 3'.
self updateLabel.
]
{ #category : #updating }
SpRadioButtonExample >> updateLabel [
label
label:
(String
streamContents: [ :s |
{button1 . button2 . button3}
do: [ :button |
s
<< button label;
<< ' : ';
<< (button state ifTrue: [ 'V' ] ifFalse: [ 'X' ]) ]
separatedBy: [ s << ' - ' ] ])
]