| 1217 | } |
| 1218 | |
| 1219 | void 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 | |
| 1257 | ReferenceCountedObject* ScriptingApi::Content::ScriptComponent::getCustomControlCallback() |
| 1258 | { |
no test coverage detected