We are looking for a way to determine whether or not each visualization is in focus or not. If for example a web visualization is not in focus (i.e. minimized) we want the program to terminate. Are there any built in methods for tracking visualization focus? or alternatively, would it be easier to write a script in another language to track if a visualization is in focus, then relay the information back to the codesys program? Other alternate solutions would be welcome as well.
Please let me know if there are any additional solutions.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
do you know if there are any javascript APIS available which allow the detection?
If the browser doesn't tell the website it lost the focus, not much the webvisu can do?
I know there are several Javascript methods which will return a boolean based on whether or not the tab is in focus. However, I am unsure about how to call this javascript method for each instance of the visualization.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You're right, I thought this was a method which could be used with a window. Another idea we had however was to have a signal which only triggers when a user is viewing a given visualization. If the user changes visualization, the signal stops, and another program can be executed to stop the program.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all.
We are looking for a way to determine whether or not each visualization is in focus or not. If for example a web visualization is not in focus (i.e. minimized) we want the program to terminate. Are there any built in methods for tracking visualization focus? or alternatively, would it be easier to write a script in another language to track if a visualization is in focus, then relay the information back to the codesys program? Other alternate solutions would be welcome as well.
Please let me know if there are any additional solutions.
Hello @jackcaissey,
do you know if there are any javascript APIS available which allow the detection?
If the browser doesn't tell the website it lost the focus, not much the webvisu can do?
@dgirard are you having the same use case?
Best regards
Marcel
I know there are several Javascript methods which will return a boolean based on whether or not the tab is in focus. However, I am unsure about how to call this javascript method for each instance of the visualization.
e.g?
for example the hasFocus() method
document.hasFocus() referes to dom nodes having a tab focus.
https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus
It does not represent the state if a website is in the foreground or not minimized.
You're right, I thought this was a method which could be used with a window. Another idea we had however was to have a signal which only triggers when a user is viewing a given visualization. If the user changes visualization, the signal stops, and another program can be executed to stop the program.
Hi @m.prestel, yes I am working on this with @jackcaissey
We are having a similar discussion in this thread with @Chris.O and @Iota: https://forge.codesys.com/forge/talk/Visualization/thread/b12815b7cd/?page=1&limit=25#6941
As far as I understand it the other thread is more focused on a watchdog feature for buttons.
I think it differs from your request to detect if a tab is invisible.
Best regards,
Marcel