Skip to main content
Participating Frequently
September 5, 2022
Question

Is there any events associated with UNDO command?

  • September 5, 2022
  • 1 reply
  • 260 views

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.

This topic has been closed for replies.

1 reply

Mylenium
Legend
September 5, 2022

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

VarianttiAuthor
Participating Frequently
September 5, 2022

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...