Show default preset name on first launch
-
This is the top bar of my plugin when I open the project in HISE. The default preset
00 INITloads, sets the knob values and shows the preset browser.
This is the top bar of my plugin on first launch in a DAW. The default preset
00 INITloads and sets the knob values, but doesn't show in the preset browser.
Is this intended behaviour or a bug?
The preset browser is fully functional - I can load any preset, and the first click of the
>icon does show the00 INITpreset. I'm just surprised it doesn't show on launch.If the plugin knows to load the default preset, shouldn't it also know to show the name in the preset browser?
I expected:
- on first launch (no DAW session data), the default preset loads and shows in the preset bar
- on subsequent launch from a saved DAW session, the saved state should load
-
@dannytaurus said in Show default preset name on first launch:
Is this intended behaviour or a bug?
Depends on your script.
I use this in mine
const uph = Engine.createUserPresetHandler(); uph.setPostCallback(function(presetFile) { updatePresetLabel(); // Name display handled here }); -
@dannytaurus I've just hit this problem for the 100s time a couple of days ago and it alway melts my brain...
What I do is to force "init" in the postCallback when the presetFile is undefined, meaning it's init time...
Another way could be to save the label in preset, but this only brought me more pain down the line
-
@David-Healey said in Show default preset name on first launch:
updatePresetLabel
What does your
updatePresetLabel()look like? Because I have the following already, but it's setting the text to"":UserPresetHandler.setPostCallback(function(presetFile) { btnShowPresetBrowser.set("text", Engine.getCurrentUserPresetName()); });Seems like on first launch,
Engine.getCurrentUserPresetName()returns"". -
inline function updatePresetLabel(nameOnly: number) { if (!isDefined(currentPresetFile)) return; local category = currentPresetFile.getParentDirectory().toString(currentPresetFile.NoExtension); local name = currentPresetFile.toString(currentPresetFile.NoExtension); if (nameOnly) btnPresetBrowser.set("text", name); else btnPresetBrowser.set("text", category + " | " + name); }I also call this in the post save callback too.
-
@ustk Good call. Claude suggested I update to this:
UserPresetHandler.setPostCallback(function(presetFile) { // On first launch the default preset loads with no file (frontend leaves // currentlyLoadedFile empty), so getCurrentUserPresetName() is "". Fall back // to the default preset name. (Editor returns the real name, so it's unaffected.) var name = Engine.getCurrentUserPresetName(); btnShowPresetBrowser.set("text", name != "" ? name : "00 INIT"); });I'll try it and make sure it works on first launch, and doesn't interfere with reloading DAW sessions.