Copy link to clipboard
Copied
is there an event listener for when a CEP panel is opened.
i have a persistent panel so the onload only works when the panel is opened for the first time. i want to keep it persistent, but i want to know when the panel is being opened again
Perhaps I have misunderstood something, because my English is bad. Unfortunately listener for events at the opening of the panel, I also did not find, so I had to go a roundabout way.
Copy link to clipboard
Copied
if you html5 panel, try: window.addEventListener ( 'focusin', function ( event ) {});
Copy link to clipboard
Copied
thanks alex, but that event triggers every time the user interacts with the panel. even if the panel never lost focus.
i had also tried focus, but that too triggers too many times. i want to know explicitly when the panel opens/expands.
Copy link to clipboard
Copied
how about resize?
Copy link to clipboard
Copied
resize does trigger when panel is closed.
@Alexander. ill try your solution. I was really just wondering if there was an event listener for that particular event. I Have a panel with peristent information and i want to reset some vars when a new session starts and keep others. So i dont want to close and reopen the panel and lookin for an even that only happens once the panel is deliberaly engaged.
so i was just wondering if the panel open was an actual event as i find the cep documentation very lacking.
Copy link to clipboard
Copied
Perhaps I have misunderstood something, because my English is bad. Unfortunately listener for events at the opening of the panel, I also did not find, so I had to go a roundabout way.
Copy link to clipboard
Copied
And what purpose do you have? In Adobe Illustrator panel is loaded and there until the closure of the program or to a function call new CSInterface().closeExtension(); After calling this function, re-open your extension.
You can try another option.
Create a <input type="hidden" id="isActiveExt" value="0" />
And add 2 events:
window.addEventListener( 'focus', function ( event ) {
var obj = document.querySelector('#isActiveExt');
if ( !parseInt( obj.value ) ) {
obj.value = 1;
// your code
console.log( 'Extension is active!' );
}
});
window.addEventListener( 'blur', function ( event ) {
var obj = document.querySelector('#isActiveExt');
if ( parseInt( obj.value ) ) {
obj.value = 0;
console.log( 'Extension is deactive!' );
}
});
Find more inspiration, events, and resources on the new Adobe Community
Explore Now