"Mark Wilden" <
[hidden email]> wrote in message
news:
[hidden email]...
> I'm trying to set a presenter's typeconverter in code, rather than in
VC[1].
> The trouble is that the presenter/model is read-only, yet setting its
view's
> typeconverter sends value: back to the model.
...
> The trouble is that if "somewhere" is after model:, then
> View>>typeconverter: will update the model, and the value doesn't have a
> setter (it's read-only). If "somewhere" is before model:, then usually the
> presenter's view is just DeafObject.
I wonder if typeconverter: should perhaps be overridden in
StaticViewAbstract so that it uses displayValue: rather than value:?
There are two tricks you could use to force the system to work the way you
want it to. Neither looks elegant to me, and both seem to be fighting the
current. In my example I am using the size of an array to simulate your
situation. See bellow.
"Create and set model."
te := TextEdit show.
te model: (#() aspectValue: #size).
"1st Way"
tmp := te model.
te model: nil.
te typeconverter: NumberToText new.
te model: tmp.
"2nd Way (this could be expanded to check the actual message to avoid
handling an unanticipated error)"
[te typeconverter: NumberToText new] on: MessageNotUnderstood do: [:err | ].
Chris