Copy link to clipboard
Copied
Hello,
is there a list of Panel's related (minimized, closed, iconized, moved, resized, etc) events that are supported so far?
Thank you
Davide Barranca
(Link removed)
Copy link to clipboard
Copied
Bump!
Copy link to clipboard
Copied
Does the list here not help? : http://adobe.ly/1cWBggl
Copy link to clipboard
Copied
Hallgrimur,
you read my mind - I was exactly on that PDF!
Besides:
which are about the host app and its open documents (say Photoshop and an open image), talking about strictly Panel's stuff, there's only the possibility to RegisterExtensionUnloadCallback() - that is, before the extension closes, am I right? No resize / collapse events if I understand correctly (to my needs the unload is enough).
Also, do I get it right that GetWorkingDirectory(), IsRunning(), OnQuit(), they all refer to Processes - that is external commands such as "ls" in the terminal - and not the extension (the panel) itself?
Thank you!
Davide
----
UPDATE
As a side note, it's not clear from the CC_Extension_SDK.pdf that we should use it like "window.cep.category.method", where category is either fs, process, util, encoding. You get it if you inspect the source code.
Copy link to clipboard
Copied
Hi,
There is no resize/collapse event at this time. I'm copying a response to a similar question raised elsewhere:
This API is to register a callback which can be triggered while unloading extension. But no heavy or blocking code is expected in this callback. Here I think alert is sort of blocking call to show up a message box, but you could try to use console.log or example below to see if this callback is working.
Example
window.cep.util.registerExtensionUnloadCallback(function(){
window.cep.fs.writeFile("C:
test.txt", "Hello");
});
Also please keep in mind that there're some limitations for this API.
1. If registerExtensionUnloadCallback is called more than once, the last callback function that's successfully registered will be used.
2. The callback function must be context-independent and it is executed in the mainframe's context.
3. The callback function must not use APIs defined in CSInterface.js.
The GetWorkingDirectory(), IsRunning(), OnQuit() callbacks are not 'events' like documentAfterActivate, documentAfterDeactivate and the others you listed. You are correct that it refers to external processes, like 'ls'. But external processes can be any executable programs or scripts. You could write to a database oor ftp a file or copy a folder. Whatever you want to do.
Best regards,
Hallgrimur
--
Hallgrimur Th. Bjornsson | Product Manager | Adobe | Tel: ( removed)
Copy link to clipboard
Copied
Hallgrimur,
as I've had the opportunity to tell you elsewhere, it seems like the provided code for window.cep.util.registerExtensionUnloadCallback doesn't work for me on OSX / PS CC.
I'll look into the new events as well, thank you for the list!
Kind regards
Davide Barranca
(Link removed)
Copy link to clipboard
Copied
Hi Hallgrimur,
This code is not working for me either (Photoshop CC 2014 host on Windows 8 x64).
Is there an alternative for catching the event when the extension is being closed by the user that we can use?
Arturo.
Copy link to clipboard
Copied
As of 2017 I also need to catch the close panel event to make same safety checks on the document right before the extension is unloaded.
I hope the event "com.adobe.csxs.events.ExtensionUnloaded" is going to work some day on panels, because it seems to be predestined for the purpose. But I found a workaround so far which is tested on Photoshop CC 2017 / MacOS, CSXS v. 7.0
You can use "com.adobe.csxs.events.WindowVisibilityChanged". It just fires on persistent panels in my attempts. Here's the main.js to test panel visibility (opening/closing the panel) and ExtensionUnloaded (doesn't fire at all):
(function() {
'use strict';
var fs = require('fs');
var csInterface = new CSInterface();
var gExtensionId = "YOUR_EXTENSION.extension";
// activate persistence
var persistence = new CSEvent("com.adobe.PhotoshopPersistent", "APPLICATION");
persistence.extensionId = gExtensionId;
csInterface.dispatchEvent(persistence);
console.log('panel window events:');
/* activate document event: working on both persistent and non-persistent panels */
new csInterface.addEventListener("documentAfterActivate", function(event) {
console.log('activated doc: ' + event.data);
})
/* collapse/open panel: just working on persistent panels */
new csInterface.addEventListener("com.adobe.csxs.events.WindowVisibilityChanged", function(event) {
console.log('window visibility: ' + event.data);
fs.writeFile("/Users/OSX_USERNAME/Desktop/visibilitychanged.txt", 'visibility changed', function(err) {
if (err) { console.log(err); }
});
});
/* unload panel: not working at all on panels */
new csInterface.addEventListener("com.adobe.csxs.events.ExtensionUnloaded", function(event) {
console.log('extension unloaded: ' + event.data);
fs.writeFile("/Users/OSX_USERNAME/Desktop/unloaded.txt", 'extension is unloaded', function(err) {
if (err) { console.log(err); }
});
});
}());
If you want your panel to be non-persistent here's a workaround, which is not a beauty but it works.
Just set the "PhotoshopUnPersistent" flag when collapsing the persistent panel:
/* workaround for "ExtensionUnloaded" by toggling persistence */
new csInterface.addEventListener("com.adobe.csxs.events.WindowVisibilityChanged", function(event) {
console.log('window visibility: ' + event.data);
fs.writeFile("/Users/OSX_USERNAME/Desktop/visibilitychanged.txt", 'visibility changed', function(err) {
if (err) { console.log(err); }
});
var unPersistence = new CSEvent("com.adobe.PhotoshopUnPersistent", "APPLICATION");
unPersistence.extensionId = gExtensionId;
csInterface.dispatchEvent(unPersistence);
});
(remember to adjust the extension name and path on writeFile - but logging suffices)
The workaround assumes that the panel is set to persistent on start. I could verify that persistence actually switches with some status flags in the html/js file.
---
related links:
a (closed) Github issue on "ExtensionUnloaded" - hope it will come to panel extensions, too:
Copy link to clipboard
Copied
Any development on this topic since 2014?
I need a consistent way to catch when user closes/minimizes/iconizes the panel back to CC 2015.5
Copy link to clipboard
Copied
Hi,
I want to do the same, I am able to call the function but the panel closes first but I want to close the panel after executing my function-
Copy link to clipboard
Copied
The latest Photoshop also supports these events:
com.adobe.PhotoshopPersistent
com.adobe.PhotoshopUnPersistent
com.adobe.PhotoshopCallback
com.adobe.PhotoshopWorkspaceSet
com.adobe.PhotoshopWorkspaceGet
com.adobe.PhotoshopWorkspaceAware
com.adobe.PhotoshopWorkspaceData
com.adobe.PhotoshopWorkspaceRequest
com.adobe.PhotoshopRegisterEvent
com.adobe.PhotoshopUnRegisterEvent
com.adobe.PhotoshopLoseFocus
com.adobe.PhotoshopQueryDockingState
Best regards,
Hallgrimur
--
Hallgrimur Th. Bjornsson | Product Manager | Adobe | Tel: +44 (0) 1314582787