I have a popup with a button. When I click (in Browser) or touch (in mobile app) I want the button to set a custom property tag value to 1, then close my popup. I am not getting the desired results.
1st attempt- I used the onClick event and configured a script to set the tag as Action #1, then used Popup action #2 to close the popup. Result- Script does not run, popup closes.
2nd attempt- I used onMouseDown event and configured a script to set the tag. I used onMouseUp event and the Popup action to close the popup. Result- Script fires and popup closes in browser with mouse. Script does not fire and popup closes in mobile app.
3rd attempt- I used onMouseDown event configured a script to set the tag. I disabled the onMouseUp event to close the popup. Result- Script fires successfully in both the browser and mobile app. (it appears here that the onMouseDown script does work for the mobile appâŚ)
4th attempt- I used onMouseDown event configured a script to set the tag. I used onMouseUp event and the Popup action to close the popup. I added onTouchStart event and configured a script to set the tag. I used onTouchEnd event and the Popup action to close the popup. Result- Script fires and popup closes in browser with mouse. Script does not fire and popup closes in mobile app.
5th attempt- I used onTouchStart event and configured a script to set the tag. I used onTouchEnd event and the Popup action to close the popup. Result- Script does not work and popup does not close in browser with mouse. Script does not fire and popup closes in mobile app.
Suggestions? I canât get the same behavior in both the browser and mobile app. Vision allowed scripting to both set tags and open/close windows within the same script. Can you script closing a popup in Perspective or do you have to use the popup action?
Thanks-
Thanks for the assistance. I was using the action called popup to open the popup and I was passing in a unique (indirect) popup id. I had to change this to some other unique id since the popup that was being called to open didnât have access to the unique id. I would have had to go back through and pass that variable up to the popup for the only purpose of being able to close it. Iâm saving myself some workâŚanyways it is functioning the way I want now.
To follow up on some of my original issues- When I stack different actions within an event in a certain order, why did it appear they were not functioning in that order? (see my first attempt description above) By being able to order the actions, it implies they will be executed in that order, but maybe not? Even separating the action into different events of mouse down/mouse up doesnât seem to have the desired results. Also some inconsistencies between what works for an event (ie onMouseDown) in the browser vs. mobile app. (See 2nd attempt). I would expect onMouseDown not to work at all in the mobile app and force you to use onTouchStart. If you could provide some further explanation on how the events work that would be helpful. Thanks again.
The events and how theyâre handled are (unfortunately) up to the individual device and React, not anything weâre handling in our code.
Actions are fired in order, but thereâs one (huge) caveat: any action that has to run on the gateway (ie, scripting, since the actual browser canât run Python code) is basically invoked âasynchronouslyâ. Thereâs no way for the frontend in your browser to âblockâ while waiting for a Python script to run - even if we did implement some JS interrupt, what happens if the script youâre trying to run on the gateway errors out? Or takes minutes to finish?
So, any âgateway-scopedâ action canât be relied upon to interact with a front-end object if youâre doing a âterminalâ action like closing a popup. Itâs unfortunate, and at minimum Iâd like for us to make the UI about whatâs âgateway scopedâ vs âsession scopedâ a lot clearer in the action configuration, but it is âexpected behaviorâ.
Thanks- that makes sense. Yes, maybe a clearer session vs. gateway scoped UI would be helpful. At least it would provide some insight to the user as to why things may not work as far as timing, and have the user (such as myself) take the events and actions literally as the order displayed on the screen.
Hereâs something interesting happening-
It appears that no matter what I put in the system.perspective.closePopup script as the popup id, it closes the popup anyways.
I have an event and action to open a popup, using the popup action with a unique ID of âJohn F Kennedyâ. On the popup that opens, I have a button with a script that writes to a tag value and another line in the same script to close the popup, system.perspective.closePopup( âBilly Bob Thorntonâ ). Clicking the button executes my tag write and closes the popup. It doesnât matter what I put in the script for the popup id, it closes.