38 a bufferedValueHolder keeps a temporary copy of the realHolders value, |
38 a bufferedValueHolder keeps a temporary copy of the realHolders value, |
39 and only does a real store of the value when triggered. |
39 and only does a real store of the value when triggered. |
40 Triggering is done by depending on a trigger objects value, which is |
40 Triggering is done by depending on a trigger objects value, which is |
41 typically a ValueHolder for a boolean, which is set by an ok-button. |
41 typically a ValueHolder for a boolean, which is set by an ok-button. |
42 |
42 |
43 Notice: this class was implemented using protocol information |
43 Notice: |
44 from alpha testers - it may not be complete or compatible to |
44 this class was implemented using protocol information |
45 the corresponding ST-80 class. If you encounter any incompatibilities, |
45 from alpha testers - it may not be complete or compatible to |
46 please forward a note to the ST/X team. |
46 the corresponding ST-80 class. |
|
47 If you encounter any incompatibilities, please forward a note |
|
48 describing the incompatibility verbal (i.e. no code) to the ST/X team. |
47 |
49 |
48 [author:] |
50 [author:] |
49 Claus Gittinger |
51 Claus Gittinger |
50 " |
52 " |
51 ! |
53 ! |
52 |
54 |
53 examples |
55 examples |
54 " |
56 " |
55 unbuffered (values are changed, even if not accepted, |
57 unbuffered (values are changed, even if not accepted, |
56 iff a field is left with Return or accept is done in a field): |
58 iff a field is left with Return or accept is done in a field): |
57 |
59 [exBegin] |
58 |firstName lastName dialog| |
60 |firstName lastName dialog| |
59 |
61 |
60 firstName := 'foo' asValue. |
62 firstName := 'foo' asValue. |
61 lastName := 'bar' asValue. |
63 lastName := 'bar' asValue. |
62 |
64 |
63 dialog := Dialog new. |
65 dialog := Dialog new. |
64 (dialog addTextLabel:'Name:') layout:#left. |
66 (dialog addTextLabel:'Name:') layout:#left. |
65 dialog addInputFieldOn:firstName. |
67 dialog addInputFieldOn:firstName. |
66 dialog addVerticalSpace. |
68 dialog addVerticalSpace. |
67 (dialog addTextLabel:'Address:') layout:#left. |
69 (dialog addTextLabel:'Address:') layout:#left. |
68 dialog addInputFieldOn:lastName. |
70 dialog addInputFieldOn:lastName. |
69 |
71 |
70 dialog addAbortButton; addOkButton. |
72 dialog addAbortButton; addOkButton. |
71 |
73 |
72 dialog open. |
74 dialog open. |
73 |
75 |
74 Transcript show:firstName value; show:' '; showCr:lastName value |
76 Transcript show:firstName value; show:' '; showCr:lastName value |
|
77 [exEnd] |
75 |
78 |
76 |
79 |
77 buffered (values are only stored when accepted; undo reloads old values) |
80 buffered (values are only stored when accepted; undo reloads old values) |
78 (use an instance of TriggerValue. If a ValueHolder was used, we had |
81 (use an instance of TriggerValue. If a ValueHolder was used, we had |
79 to temporarily set its value back to nil, to have the change really be |
82 to temporarily set its value back to nil, to have the change really be |
80 forwarded to its dependends) |
83 forwarded to its dependends) |
81 |
84 [exBegin] |
82 |firstName lastName trigger dialog| |
85 |firstName lastName trigger dialog| |
83 |
86 |
84 firstName := 'foo' asValue. |
87 firstName := 'foo' asValue. |
85 lastName := 'bar' asValue. |
88 lastName := 'bar' asValue. |
86 trigger := TriggerValue new. |
89 trigger := TriggerValue new. |
87 |
90 |
88 dialog := Dialog new. |
91 dialog := Dialog new. |
89 (dialog addTextLabel:'Name:') layout:#left. |
92 (dialog addTextLabel:'Name:') layout:#left. |
90 dialog addInputFieldOn:(BufferedValueHolder |
93 dialog addInputFieldOn:(BufferedValueHolder |
91 subject:firstName |
94 subject:firstName |
92 triggerChannel:trigger). |
95 triggerChannel:trigger). |
93 dialog addVerticalSpace. |
96 dialog addVerticalSpace. |
94 (dialog addTextLabel:'Address:') layout:#left. |
97 (dialog addTextLabel:'Address:') layout:#left. |
95 dialog addInputFieldOn:(BufferedValueHolder |
98 dialog addInputFieldOn:(BufferedValueHolder |
96 subject:lastName |
99 subject:lastName |
97 triggerChannel:trigger). |
100 triggerChannel:trigger). |
98 |
101 |
99 dialog addAbortButton; |
102 dialog addAbortButton; |
100 addButton:(Button new |
103 addButton:(Button new |
101 label:'undo'; |
104 label:'undo'; |
102 action:[trigger value:false]); |
105 action:[trigger value:false]); |
103 addOkButton. |
106 addOkButton. |
104 |
107 |
105 dialog open. |
108 dialog open. |
106 dialog accepted ifTrue:[ |
109 dialog accepted ifTrue:[ |
107 trigger value:true |
110 trigger value:true |
108 ]. |
111 ]. |
109 |
112 |
110 Transcript show:firstName value; show:' '; showCr:lastName value |
113 Transcript show:firstName value; show:' '; showCr:lastName value |
|
114 [exEnd] |
111 " |
115 " |
112 ! ! |
116 ! ! |
113 |
117 |
114 !BufferedValueHolder class methodsFor:'initialization'! |
118 !BufferedValueHolder class methodsFor:'initialization'! |
115 |
119 |