Thanks James, that's useful to know. For the moment i'm having a go implementing a control bus approach. But i think i'm having a scoping problem.
Here's a class definition for an object that's in charge of updating the position of a horizontal slider based on a value it gets from another object (the reference to this other object is held in the variable source_model). This value it retrieves corresponds to the playhead position i was working on earlier (the phasor value).
The plan was to get the 'update' instance method to run repeatedly.
TKEightStepView {
var source_model;
var window=nil;
var slider=nil;
*new{ |w, src |
^super.new.init(w,src);
}
init {arg w, src;
window=w;
source_model=src;
slider=SCSlider(w,Rect(10,10,150,40));
SystemClock.sched(0.0,{this.update; 0.025});
}
update {
if(slider!=nil,
{var val=source_model.get_position;
slider.value_(source_model.get_position)});
}
}
But here's the error i'm getting when i try to use an instance of this class
ERROR: Primitive '_SCView_SetProperty' failed.
operation cannot be called from this Process.
RECEIVER:
Instance of SCSlider { (1C6817B0, gc=40, fmt=00, flg=00, set=04)
instance variables [16]
dataptr : RawPointer 18F7F710
parent : instance of SCTopView (1C694DD0, size=19, set=5)
action : nil
background : nil
mouseDownAction : nil
mouseUpAction : nil
mouseOverAction : nil
mouseMoveAction : nil
keyDownAction : nil
keyUpAction : nil
keyTyped : nil
keyModifiersChangedAction : nil
beginDragAction : nil
canReceiveDragHandler : nil
receiveDragHandler : nil
onClose : nil
}
CALL STACK:
MethodError:reportError 1651DC30
arg this = <instance of PrimitiveFailedError>
Nil:handleError 1651C4F0
arg this = nil
arg error = <instance of PrimitiveFailedError>
Thread:handleError 1651D630
arg this = <instance of Thread>
arg error = <instance of PrimitiveFailedError>
Object:throw 1651CAF0
arg this = <instance of PrimitiveFailedError>
Object:primitiveFailed 1651C190
arg this = <instance of SCSlider>
SCSlider:value_ 1651C070
arg this = <instance of SCSlider>
arg val = 0
TKEightStepView:update 1651B950
arg this = <instance of TKEightStepView>
< FunctionDef in Method TKEightStepView:init > (no arguments or variables)
Function:awake 16505D80
arg this = <instance of Function>
arg beats = 23390.649583926002
arg seconds = 23390.649583926002
arg clock = class SystemClock
var time = 23390.649583926002
After update: 188893
I thought this might have something to do with the sched task that calls the update method having been defined in the init method (a scoping problem?). Can you see anything obviously shady with this class definition?