• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Is there any events associated with UNDO command?

Community Beginner ,
Sep 04, 2022 Sep 04, 2022

Copy link to clipboard

Copied

I have a script UI with a dropdow menu filled with layer names. My script generates new layers and those are added to the dropdown menu. But if the user perform an undo(menu command or keyboard), the layers get removed from the composition, but remain in the dropdown. I would need an event handler for the undo to call a function that updates the dropdown. Any ideas? There are ways to listen to the keyboard events but how about the menu command? 

 

Cheers.

TOPICS
Scripting

Views

53

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

I don't think that's feasible. The undo queue is just that - a linear list in the base app. It has no way of knowing what you do inside your script. ultimately the operation would simply be redoable outside the script once it has been fired. It would probably make more sense to restructure your undoGroup and which functions need to be inside and which ones outside the loop. The most straightforward approach likely is to not even have an official undo and handle it all inside the script.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

LATEST

Thanks for the quick reply. I was afraid that it would be impossible to do. I'll have to figure it out some other way, or just add a simple button to update the dropdown.

 

However, I was reading the documentation and about registering new event handlers for the window object and came up with this:

 

var newWindow = new Window("palette", "", undefined);
newWindow.addEventListener("mouseover", myFunction );
 
function myFunction() {
alert("mouseover the window");
updateDropdown();
}
 
That event fires every time the mouse enters the window. If the mouse has been on the AE menu pressing Undo then it must have left the script window and re-enter to interact with the script. No idea how terrible idea this is... 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines