Solved Detect if the plugin UI interface is open or closed (bypass code when the ui is closed using broadcasters and listeners)
-
Is it possible to tell a piece of code to act differently depending on whether the plugin UI is open?
I understand that certain scripts in HISE already act this way on default.In my project I have a bunch of LAF and Scriptnode which create metering. I don't need these to run whilst the UI is closed.
Perhaps this is not important, as this stuff generally uses a negligible amount of resources, but I thought it was an interesting question.
-
If the script is deferred then it won't run when the UI is closed - your main interface script should always be deferred.
-
@d-healey
Thank you I will look into this.
I guess this would not help me bypass the scriptnode, but would at least allow me to stop drawing my metering.For some reason I thought that I had read somewhere that the UI stuff was automatically deferred, but that can't be the case.
Synth.deferCallbacks(true);
^ How do you implement this?
Am I able to defer a whole namespace somehow? -
This post is deleted! -
-
@Christoph-Hart
Aha! Thank you I missed this -
@griffinboy You just drop it in your on init callback and the entire script (all midi callbacks) are deferred. I thought this applied to timers as well but as Christoph points out the timers are automatically deferred.
-
@d-healey
I'm not sure if I can do what I want using Synth.deferCallbacks(true);I am firstly trying to defer my Timer script which loops and draws the UI, and then secondly to disable the scriptnode which is creating the information for the Ui.
This is for performance reasons.I think I shall have to look into what Christoph posted, it looks like I shall have to create a listener to this suspend event!
-
@griffinboy
It works perfectly using the documentation here:
https://docs.hise.dev/scripting/scripting-api/content/index.html#setsuspendtimercallbackNote* I discovered that all the repaint() routines get called when switching from a different window, back to the main interface window.
This was confusing me for a moment, making me think that my UI was still updating in the background.But no, it was successfully paused and only repainted once, when opening up the UI page,
-
-
-
@griffinboy
For those who want to see the working code: -
@griffinboy thanks for posting this, it wasn't something I had given much thought to previously, but my newer projects could benefit greatly from this
-
@HISEnberg
No problem,
I'm going to update this screenshot in a second to be less case specific, and with the code for altering scriptnode bypassI'll probably delete this post and just make a neat answer post.