Beginner Questions - Create Custom Callback
-
Hi there, I am very new to both scripting and HISE.
I have been working my way through the documentation and have been following along with the PhaseWizard tutorial project.
Ive been getting along fine so far and really enjoying it.However I did get stuck for a long time on the section creating custom callbacks for the combo box's
When I right clicked on the combobox, pasted into [onInit] and filled in the custom logic as follows:
WaveformGenerator.setAttribute(WaveformGenerator.WaveForm1, value);I got an error message in the console.
the callback pasted the following:
inline function onOSC1 WaveControl(component, value)
{
//Add your custom logic here...
};Content.getComponent("OSC1 Wave").setControlCallback(onOSC1 WaveControl);
I eventually found that the issue was the space between onOSC1 and WaveControl(component, value). Was this an error on my part or an issue with the way I copied the callback func to my clipboard or something else?
Thanks, Tom
-
@tomekbruml Though the name string of the component can have spaces, the function's name cannot contain any space, no more than for a variable name for instance.
-
@ustk Thankyou! I am surprised then that a space is included when creating custom callback from selection.
-
@tomekbruml Indeed, that's weird. HISE doesn't complain if you give a component an id using spaces...
And it outputs the CB accordingly:inline function on Knob 1 with SpaceControl(component, value) { //Add your custom logic here... }; Content.getComponent(" Knob 1 with Space").setControlCallback(on Knob 1 with SpaceControl);
But you must never use spaces when defining your component's ids.
-
@Matt_SF Mmm... ere you presented it with spaces, which shouldn't be the case, or was it intentional?
@tomekbruml I have never encountered this issue, here's what you should get from right click "Create custom callback from selection"
inline function onKnob1Control(component, value) { //Add your custom logic here... }; Content.getComponent("Knob1").setControlCallback(onKnob1Control);
Are you using the develop branch?
What operating system? -
@ustk yes I intentionally gave the knob an id with spaces to see how HISE would react, and it doesn't complain at all. Creating a CB using the right click menu ends up to be what I posted.
HISE should tell the user not to use spaces in the component's id.Edit: damn auto correct
-
@Matt_SF Oh I see! My bad! I just couldn't think you could name a component with spaces, this is so unnatural, I wasn't able to follow here