I have forgotten how to arrange for a subclass of dialog to pass input
values to a model and then display the results. I have a dialog that has
some numeric fields which are inputs and some other numeric fields that are
outputs and there is a button the user clicks that should cause the dialog
to pass the inputs to the model and then have the outputs updated. The model
is called a DiscModel and the Presenter is called DiscDialog and in the
createComponents I have
super createComponents.
outerPresenter := self add: NumberPresenter new name: 'outer'.
innerPresenter := self add: NumberPresenter new name: 'inner'.
anglePresenter := self add: NumberPresenter new name: 'angle'.
widthPresenter := self add: NumberPresenter new name: 'width'.
lengthPresenter := self add: NumberPresenter new name: 'length'.
profilePresenter := self add: NumberPresenter new name: 'profile'.
the first three are inputs and the second three are outputs.
and in the model: method of the presenter I have put:
model: aDiscModel
"Set the model associated with the receiver."
| aspectBuffer |
super model: aDiscModel.
aspectBuffer := self model.
outerPresenter model: (aspectBuffer aspectValue: #outer).
innerPresenter model: (aspectBuffer aspectValue: #inner).
anglePresenter model: (aspectBuffer aspectValue: #angle).
widthPresenter model: (aDiscModel width).
lengthPresenter model: (aDiscModel length).
profilePresenter model: (aDiscModel profile).
but the values in the fields are not updating properly
Thanks
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4654 (20091202) __________
The message was checked by ESET NOD32 Antivirus.
Try:
widthPresenter value: (aDiscModel width).
lengthPresenter value: (aDiscModel length).
profilePresenter value: (aDiscModel profile).
Regards,
Bruno
Or:
widthPresenter model: (aDiscModel width asValue).
lengthPresenter model: (aDiscModel length asValue).
profilePresenter model: (aDiscModel profile asValue).
It depends on what you want...
Regards,
Bruno
Thanks Bruno, but no it still doesn't update. Should I have something called
createSchematicWiring or something to trigger updates in the "Calculate"
button handler?
Graham
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4655 (20091202) __________
> Thanks Bruno, but no it still doesn't update. Should I have something called
> createSchematicWiring or something to trigger updates in the "Calculate"
> button handler?
If the inputs are changed and the you need to recalculated it, then
you need:
createSchematicWiring
super createSchematicWiring.
outerPresenter when: #valueChanged send: #updateOutputs to: self.
innerPresenter when: #valueChanged send: #updateOutputs to: self.
anglePresenter when: #valueChanged send: #updateOutputs to: self.
updateOutputs
model doSomeStuff.
widthPresenter value: (model width).
lengthPresenter value: (model length).
profilePresenter value: (model profile).
Every time you modify any of outerPresenter, innerPresenter ,
anglePresenter the #updateOutputs should be triggered.
Regards,
Bruno
Thats it! Great - thanks Bruno. Merry Christmas!