The ObjectController is a controller that forwards the model to its Views.
This is especially helpful if a View represents a object. while other Views modify it, using MethodController.
If a MethodController is used to change the model it calls MethodController:updateViews, as long as updateObjectOnChange is true (default) the ObjectControllers associated with the model are updated as well. By this the View that represents the Object is kept in sync.
Create a ObjectController
model |
The Object that holds the data |
spec |
A ControlSpec that specifies the data of the Model. The spec is used to unmap the data to the 0 to 1 range used by many Views. The default value is a NonSpec a spec that does not specify anything. |
msg |
msg is by default \objectControllerSync . |
a ObjectController
getter gets the unmaped data from the model ( making use of the spec of the ObjectController )
setter maps and sets the data in the model ( making use of the spec of the ObjectController )
val |
If a ControlSpec is specified it would usually be a number in the range 0 to 1 |
If a ControlSpec is specified the getter usually returns a number in the range 0 to 1
getter gets the data from the model.
setter sets the data in the model.
val |
the data from the model.
calls MethodController: -value for compatibility with Streams
shortcut for linkInput
Links to a object ( often a View ) so that the object is updated on a models change.
Linking means here a one directional connection.
The object/view gets the model as unmaped by the provided spec.
obj |
Object to be linked. Often a View. |
objset |
Method used to set data in the View. Default is \value_. Either Symbol, Array, or Function ( see MethodController: *new modelget ) |
spec |
A ControlSpec that can be used to map the values returned by MethodController: -input to the range of the View() |
links a model to a object ( often a View ) so that the object is updated on a models change.
linking means here a one directional connection.
obj |
Object to be linked. Often a View. |
objset |
Method used to set data in the View. Default is \value_. Either Symbol, Array, or Function ( see MethodController: *new modelget ) |
spec |
A ControlSpec that can be used to map the values returned by MethodController: -value to the range of the View() |
update is called by model.changed( msg ).
if the model might have changed but one is not sure one can use this method to update the linked Views.
releases or unlinks the obj.
unlink is assiged to be called by View:onClose automatically if View:onClose is not overwritten by another function. If the Object is not a View it has to be called explicitly to avoid memory leaks.
obj |
object to be released |
Remove this ObjectController from its models dependancy.
If all links are released it is called automatically, because calling MethodController:update would be of no use.
replaces the model
newModel |
Model to replace the old model. |
Search for ObjectController in the examples in the MethodController documentation.