SuperCollider CLASSES

SimpleController

Controller according to the model-view-controller (M-V-C) paradigm
Inherits from: Object

Description

SimpleController can be used as a controller according to the model-view-controller (M-V-C) paradigm. It provides an IdentityDictionary of actions, which are called whenever the attached model sends a notification by calling changed.

Class Methods

*new (model)

Creates a SimpleController instance with the model to be observed.

Arguments:

model

An object of any class

Inherited class methods

Instance Methods

-put (what, action)

Arguments:

what

Register an action, which is called when the model invokes changed(what, moreArgs).

action

Action to register.

-remove

Remove a registered action.

Arguments:

(action)

Action to remove

Inherited instance methods

Undocumented instance methods

-removeAt (what)

Examples

(
var controller, model, view;

model = Ref(0.5);
controller = SimpleController(model);
controller.put(\value,
    {|theChanger, what, moreArgs|
        view.value_(theChanger.value);
    });

view = Slider(Window("slider", Rect(100, 100, 330, 38)).front, Rect(5, 5, 320, 20));
view.onClose_{controller.remove};

// run a routine to change the model's value:
r{
    100.do{
        model.value_(1.0.rand.postln).changed(\value);
        0.5.wait;
    }
}.play(AppClock)
)