Hide preset browser when saving a preset.
-
So, ive been having a hard time with this.
I am using a floating tile for the Preset Browser, and a button to hide/unhide it, which works.
But how can i do the same with the build-in "Save preset" button?This does not work:
const var FloatingTile1 = Content.getComponent("FloatingTile1"); function onPresetSavedCallback() { // Logic to make the floating tile invisible FloatingTile1.set("visible", false); } // Set the post preset save callback to the function UserPresetHandler.setPostPresetSaveCallback(onPresetSavedCallback);
Just throws a:
Unknown function 'setPostPresetSaveCallback'Ive been trying to get chatGPT to help me, without any luck.
Any help is appreciated!
-
@xxanx I think you need to define
const UserPresetHandler = Engine.createUserPresetHandler();
first and also the the function is
.setPostSaveCallback()
not setPostPresetSaveCallback
-
@alhug said in Hide preset browser when saving a preset.:
.setPostSaveCallback()
Thanks,
This seems to work, sort of (it closed the preset browser right away when clicking save preset):
const var uph = Engine.createUserPresetHandler(); uph.setPostSaveCallback(function() { // Logic to make the floating tile invisible after a preset is loaded FloatingTile1.set("visible", false); });
However, the preset browser prompts the user the overwrite the preset, so its actually not working correctly. The preset browser still shows up when clicking "previous" or "next"
-
@xxanx said in Hide preset browser when saving a preset.:
The preset browser still shows up when clicking "previous" or "next"
Do you have your show preset browser button set to saveInPreset enabled?
-
Yes, i do.
But either way, the issue still persists.
When i click previous or next buttons, and open the browser the "Overwrite prompt" is still there. -
@xxanx Each time you switch preset it's triggering that button and showing you your preset browser again :)
-
Thanks!
However if its on or off, the issue still persists.
When i click previous or next buttons, and click the browser button the "Overwrite prompt" is still there.And "tempFileBeforeMove" shows up in the preset name text "label"
-
@xxanx said in Hide preset browser when saving a preset.:
When i click previous or next buttons, and click the browser button the "Overwrite prompt" is still there.
I guess you've found an issue that the post save callback fires at the wrong time. @Christoph-Hart Can this be moved to fire after the confirmation?
-
@d-healey
I believe so yes, it should fire after the overwrite prompt.
I wonder if its possible to add a timer? (wait 1 second) before running it?
Just as a temporary quick fix. -
@xxanx Yeah you could do that
-
Still having issues with closing the preset browser when overwriting a preset, do you have an example of using a timer?
-
This is what i have so far:
(rough code i think)// SHOW AND HIDE PRESET BROWSER WITH BUTTON const var FloatingTile1 = Content.getComponent("FloatingTile1"); const var Button1 = Content.getComponent("Button1"); Button1.setControlCallback(Button1CB); inline function Button1CB(control, value) { FloatingTile1.showControl(value); }; // Close Preset browser after save const var uph = Engine.createUserPresetHandler(); uph.setPostSaveCallback(function() { // Logic to make the floating tile invisible after a preset is saved FloatingTile1.set("visible", false); Button1.setValue(false); // Update the button state to match the FloatingTile visibility }); uph.setPostCallback(function() { // Logic to make the floating tile invisible after a preset is loaded FloatingTile1.set("visible", false); Button1.setValue(false); // Also update the button state here to ensure consistency });
-
@xxanx
Figured it out.
In case anyone else wants a preset browser that kinda works, with opening and closing (with preset overwrite prompt)
heres my code:// SHOW AND HIDE PRESET BROWSER WITH BUTTON const var FloatingTile1 = Content.getComponent("FloatingTile1"); const var Button1 = Content.getComponent("Button1"); Button1.setControlCallback(Button1CB); inline function Button1CB(control, value) { FloatingTile1.showControl(value); }; // Timer for handling delay after saving a preset const var saveTimer = Engine.createTimerObject(); var saveTimerCounter = 0; saveTimer.setTimerCallback(function() { if (saveTimerCounter > 0) { saveTimerCounter--; if (saveTimerCounter == 0) { FloatingTile1.set("visible", false); Button1.setValue(false); saveTimer.stopTimer(); } } }); // Close Preset browser after save const var uph = Engine.createUserPresetHandler(); uph.setPostSaveCallback(function() { saveTimerCounter = 1; // Set the counter for a brief delay saveTimer.startTimer(5500); // 500 milliseconds delay }); // Logic for handling preset loading (remains unchanged) uph.setPostCallback(function() { FloatingTile1.set("visible", false); Button1.setValue(false); });