MCPcopy Create free account
hub / github.com/christophhart/HISE / setControlCallback

Method setControlCallback

hi_scripting/scripting/api/ScriptingApiContent.cpp:1219–1255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1217}
1218
1219void ScriptingApi::Content::ScriptComponent::setControlCallback(var controlFunction)
1220{
1221 auto obj = dynamic_cast<HiseJavascriptEngine::RootObject::InlineFunction::Object*>(controlFunction.getDynamicObject());
1222
1223 if(auto h = dynamic_cast<scriptnode::DspNetwork::Holder*>(getScriptProcessor()))
1224 {
1225 if(auto n = h->getActiveNetwork())
1226 {
1227 if(controlFunction.isObject() && n->isForwardingControlsToParameters())
1228 {
1229 reportScriptError("This script processor has a network that consumes the parameters");
1230 }
1231 }
1232 }
1233
1234 if (obj != nullptr)
1235 {
1236 int numParameters = obj->parameterNames.size();
1237
1238 if (numParameters == 2)
1239 {
1240 customControlCallback = controlFunction;
1241 }
1242 else
1243 {
1244 reportScriptError("Control Callback function must have 2 parameters: component and value");
1245 }
1246 }
1247 else if (controlFunction.isUndefined() || controlFunction == var())
1248 {
1249 customControlCallback = var();
1250 }
1251 else
1252 {
1253 reportScriptError("Control Callback function must be a inline function");
1254 }
1255}
1256
1257ReferenceCountedObject* ScriptingApi::Content::ScriptComponent::getCustomControlCallback()
1258{

Callers 8

MainInterface.jsFile · 0.80
Interface.jsFile · 0.80
Interface.jsFile · 0.80
IRLogic.jsFile · 0.80
SampleMapLogic.jsFile · 0.80
Interface.jsFile · 0.80

Calls 7

varFunction · 0.85
getDynamicObjectMethod · 0.45
getActiveNetworkMethod · 0.45
isObjectMethod · 0.45
sizeMethod · 0.45
isUndefinedMethod · 0.45

Tested by

no test coverage detected