ObjectController:
Filter:
MethodController/Classes (extension) | MethodControllerQuark

ObjectController
ExtensionExtension

A Controller that links an object to another Object like a View or Synth

Description

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.

Class Methods

.new

Create a ObjectController

Arguments:

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 .

Returns:

a ObjectController

Instance Methods

.input

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 )

Arguments:

val

If a ControlSpec is specified it would usually be a number in the range 0 to 1

Returns:

If a ControlSpec is specified the getter usually returns a number in the range 0 to 1

.value

getter gets the data from the model.

setter sets the data in the model.

Arguments:

val

Returns:

the data from the model.

.next

calls MethodController: -value for compatibility with Streams

.link

shortcut for linkInput

.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.

Arguments:

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()

.linkValue

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.

Arguments:

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

update is called by model.changed( msg ).

.updateLinks

if the model might have changed but one is not sure one can use this method to update the linked Views.

.unlink

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.

Arguments:

obj

object to be released

.remove

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.

.replaceModel

replaces the model

Arguments:

newModel

Model to replace the old model.

Examples

Search for ObjectController in the examples in the MethodController documentation.