Hi! I have a script with UI, which on run stores the current Glyphs.font in a variable and works with it via the UI. However, if I run it more than once and keep the UI window open for different Glyphs.fonts, that stored currentFont variable in all of them gets overwritten by the last one, meaning all windows get the same currentFont — the last one.
Does that mean running a script with UI and keeping them all open overrides the same variables? Is it possible to open a script multiple times so that each would keep a certain Font?
But in that case I’d need to first select the correct Glyphs.font every time. No ways to store it on opening, every new run will always override the variables?
My recommendation is for script that opens a dialog that stays open and you can click a button to trigger an action.
If the script is called every time from the script menu, then all global code should run every time.
But your description suggests the former (keep the UI window open for different). So to fully understand this, I might need more information about the lifecycle of that script/UI.
Let’s say I have 3 fonts open. I select the fonts one after another and run the script for each, thus opening 3 dialogs. Each dialog should remember its own currentFont — the font which was selected when dialog opened, so that each dialog would then do actions on its font no matter what is selected. But the problem is that they all get the same currentFont — the last one.
I suppose that is because it’s the same script ran multiple times and the variables get reused, or something like that?