90
|
1 |
ValueHolder subclass:#ConvertedValue
|
258
|
2 |
instanceVariableNames:'conversion'
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Interface-Support-Models'
|
90
|
6 |
!
|
|
7 |
|
|
8 |
!ConvertedValue class methodsFor:'documentation'!
|
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
a ConvertedValue translates changes on input via a conversion block
|
|
13 |
to the output. For example, if you want to have a toggle to change the
|
|
14 |
color inputs of some other labels, use a convertedValue which translates
|
|
15 |
true/false into colors:
|
|
16 |
|
|
17 |
|toggle label converter|
|
|
18 |
|
|
19 |
converter := ConvertedValue new
|
|
20 |
conversion:[:input | input == true
|
|
21 |
ifTrue:[Color red]
|
|
22 |
ifFalse:[Color blue]];
|
|
23 |
value:false.
|
|
24 |
|
|
25 |
|
|
26 |
toggle := Toggle label:'change color'.
|
|
27 |
toggle controller pressChannel:converter.
|
|
28 |
|
|
29 |
label := Label label:'see me changing'.
|
|
30 |
label foregroundChannel:converter.
|
|
31 |
|
|
32 |
toggle open.
|
|
33 |
label open.
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
|
37 |
examples
|
|
38 |
"
|
|
39 |
examples to be added.
|
|
40 |
"
|
|
41 |
! !
|
|
42 |
|
|
43 |
!ConvertedValue methodsFor:'accessing'!
|
|
44 |
|
|
45 |
conversion:aBlock
|
|
46 |
conversion := aBlock
|
|
47 |
!
|
|
48 |
|
|
49 |
initialValue:someValue
|
|
50 |
self value:someValue
|
|
51 |
!
|
|
52 |
|
|
53 |
value:input
|
|
54 |
^ super value:(conversion value:input)
|
|
55 |
! !
|
258
|
56 |
|
|
57 |
!ConvertedValue class methodsFor:'documentation'!
|
|
58 |
|
|
59 |
version
|
|
60 |
^ '$Header: /cvs/stx/stx/libview2/ConvertedValue.st,v 1.4 1996-05-10 16:42:53 cg Exp $'
|
|
61 |
! !
|