Populate samplemaps based on folder choice(almost working)
-
@ten7kur said in Populate samplemaps based on folder choice(almost working):
setMouseCallback
I cant manage to find any example with viewports and clickEvents.
Can you point to an example? -
@ten7kur viewports dont have mouse call backs - only panels do - read the documentation:
https://docs.hise.audio/ui-components/plugin-components/index.html
-
This post is deleted! -
So how come the SamplemapList viewport is not populating on Category viewport selection?
Only populates on INIT.Im doing this in onCATControl
if(items[value] == "A"){ SamplemapList.set("items", ""); SMLdir_select = "Folder1/Sub-folderA"; SamplemapList.set("items", formattedSamplemaps.join("\n"));
-
@ten7kur Have a look at the watchtable, the samplemaps names and start/end are looking weird...
-
@ustk said in Populate samplemaps based on folder choice(almost working):
@ten7kur Have a look at the watchtable, the samplemaps names and start/end are looking weird...
Yea oops messed up along the way somewhere.
This works, but still only populates on INIT.Im trying to send the SMLdir_select from onCATControl back through the script to show the new formatedSamplemaps.
global SamplemapList = Content.getComponent("SamplemapList"); const var Sampler = Synth.getSampler("Sampler"); const var sampleMapList = Sampler.getSampleMapList(); global SMLdir_select = "Folder1/Sub-folderA";; global formattedSamplemaps = []; global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0"); global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz"); for (i = SMLdir_start+1; i < SMLdir_end; i++){ var newName = sampleMapList[i]; newName = newName.substring(10, 100); formattedSamplemaps.push(newName); } SamplemapList.set("items", formattedSamplemaps.join("\n"));
Would this solely have to be inside the onCATControl?
I did this before. It works half way. It populates Samplemaplist based on CAT Item selected but its not clearing the SamplemapList viewport. So everytime i select a CAT Item it just adds and adds to the SampemapList.
inline function onCATControl(component, value) { var items = component.get("items").split("\n"); if(items[value] == "A"){ SMLdir_select = "Folder1/Sub-folderA"; global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0"); global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz"); for (i = SMLdir_start+1; i < SMLdir_end; i++){ global newName = sampleMapList[i]; newName = newName.substring(10, 100); formattedSamplemaps.push(newName); } } else if(items[value] == "B"){ SMLdir_select = "Folder1/Sub-folderB"; global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0"); global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz"); for (i = SMLdir_start+1; i < SMLdir_end; i++){ global newName = sampleMapList[i]; newName = newName.substring(10, 100); formattedSamplemaps.push(newName); } } //else //SamplemapList.set("items", ""); SamplemapList.set("items", formattedSamplemaps.join("\n")); }; Content.getComponent("CAT").setControlCallback(onCATControl);
-
bump.
Anyone?At least the simplest of question;
Why wont a viewport clear its items with:Viewport.set("items", "");
??
Thanks -
@ten7kur said in Populate samplemaps based on folder choice(almost working):
bump.
Anyone?At least the simplest of question;
Why wont a viewport clear its items with:Viewport.set("items", "");
??
ThanksI think it's a bug. i just did a simple test and you're right, it doesn't work.
-
@ten7kur possibly try to insert viewport.changed somewhere in the code to tell the component to initiate the callback and update item list. I believe I had the viewport updating not to long ago, just not in an if statement. Might not work, just trying to help
-
@d-healey Apparently, you need to have at least something as a workaround,
likeViewport.set("items", "-");
orViewport.set("items", "Select a category");
I think
.isNotEmpty()
is the cause:void ScriptingApi::Content::ScriptedViewport::setScriptObjectPropertyWithChangeMessage(const Identifier &id, var newValue, NotificationType notifyEditor /* = sendNotification */) { if (id == getIdFor(Items)) { jassert(isCorrectlyInitialised(Items)); if (newValue.toString().isNotEmpty()) { currentItems = StringArray::fromLines(newValue.toString()); } } ScriptComponent::setScriptObjectPropertyWithChangeMessage(id, newValue, notifyEditor); }
I'll try to remove it...
-
@coreyu21 said in Populate samplemaps based on folder choice(almost working):
possibly try to insert viewport.changed somewhere in the code to tell the component to initiate the callback and update item list
Tried it but no luck..
I looked in the API, found "changed()" but it seems like it exists for all components Besides the Viewport..@ustk said in Populate samplemaps based on folder choice(almost working):
I'll try to remove it...
-
It works by commenting out the
.isNotEmpty()
condition
@d-healey I'll make a pull request to your fork in a moment if you want this fix of course...
The fact is that I don't know if it can involve a wrong behavior somewhere else in Hise, so, be warned if you use it! -
@d-healey What branch should I use in your fork? The develop seems more recent than the scriptnode one...
-
@ustk yeah the develop one
-
@ustk You're a beast! for goin nitty gritty!
Wish i could be more code efficient!..not yet! -
@ten7kur It's pushed on Dave's repo, you can compile it and test ;)
https://github.com/davidhealey/HISE/tree/develop -
@ustk said in Populate samplemaps based on folder choice(almost working):
@ten7kur It's pushed on Dave's repo, you can compile it and test ;)
https://github.com/davidhealey/HISE/tree/developAwesome stuff! Just compiled and tested it!
Thanks so much for taking your time to fix this!!Hopefully now i can finish my script