Is there a way that we can stop a script while a popup is opened?
If the running script is a loop, at the beginning of each loop you could check for a custom property on your view called “isPopupOpen” and it be defaulted to false
Then when the popup opens, send a message to the page scope, and toggle the bit true
Then when your popup closes, same thing but toggle it false again.
If the popup closing doesn’t allow you to do that. You could essentially setup a watchdog between the root container and the popup that when the popup is open, every 3 seconds it polls and sets that bit to true + a last comm time, and then the root container is every 5 seconds looking at the bit being true and the comm time being older than 5 seconds ago, if that’s the case then it sets it false
That’s just a rough idea of how you could do that, however I inherently am thinking that the script should maybe be working differently if this is what’s needed. But I don’t know anything about the script
If you need an example let me know, I can mock one up
How do you build you watchdog to valid is popup is opened?
- On the main view I created two properties, one to to interrupt the script, and one to show popup communication
- The binding on the isPopupOpen property is an expression, that checks to see if the last update was greater than 2 seconds ago
if(secondsBetween({view.custom.lastWatchdogUpdate}, now(1000)) > 2, False, True)
- Then I created a fake script that increments a gauge, but checks that the popup isnt open first, this is polling every second
currValue = self.props.value
if not self.view.custom.isPopupOpen:
if currValue >= 120:
currValue = 0
else:
currValue += 1
return currValue
- Then I added a message handler to my component, in the page scope, that sets the “lastWatchdogUpdate” property to now
- Then on my popup I created a custom property, polling at 1 second, that calls my message
system.perspective.sendMessage(messageType="watchdogUpdate", scope="page")
return value
- Then I add a button to my test view to open the popup
et. voila
Here is a copy of the project as well, let me know if you have any questions!
Popup_Interrupt_20200617143745.zip (9.3 KB)
Will try, thanks.