How can we get the UNDO event in our script? Actually my script takes the effect of the image/frame selection/desection, but with undo i don't get any selection and the result is not correct.
so, if i can get the undo event that problem can be hanled.
Thanks for your reply.
Actually this is what my script does:
1. I have a palette that has many iconbuttons in it. When i select a frame in the document, and click on an iconbutton (in the palette) , that image corresponding to that iconbutton is placed in that frame and status(statictext) is set as "Flown" inside the palette.
2. When i delete the image or the frame containing the image, the status of that image inside the palette is set as "not flown". For detecting this deletion event, i have used "afterSelectionChanged".
Now, the problem is, when i press Ctrl+Z(Undo) immediately after placing an image(currentSelection.place), i am not able to change the status in my palette, since the selection is not changed with undo( because afterSelectionChanged event is not triggered).
So, what can i do to detect undo in such a scenario.
You could attach event listener to the Undo menu action.
Example:
#targetengine "tomaxxiTEST"
( function () {
main ();
function main () {
var
beforeUndo = app.menuActions.itemByID ( 265 ).addEventListener ( "beforeInvoke", eventHandler ), // UNDO
afterUndo = app.menuActions.itemByID ( 265 ).addEventListener ( "afterInvoke", eventHandler ), // UNDO
}
function eventHandler ( evt ) {
alert ( evt.eventType + " | " + evt.currentTarget.name );
}
} ) ();
Hope that helps.
--
Marijan (tomaxxi)
Hi Marijan,
Here discussion about "undo" not a revert. both are different.... and also we can't able to do step by step process in revert methode but we can do in an undo....
do
{
try{
app.activeDocument.undo()
if(app.selection[0].constructor.name == "TextFrame")
{
//Process here
}
}
catch(e){exit()}
}while(app.activeDocument.modified == true)
You are welcome! ![]()
You can use this function to get all available menu actions with their IDs.
var
menuActions = app.menuActions,
menuActionsLength = menuActions.length,
menuActionsList = [],
newDoc = app.documents.add (),
docPage = newDoc.pages [ 0 ],
docMargins = docPage.marginPreferences,
actionsTextFrameBounds = [
docPage.bounds [ 0 ] + docMargins.top,
docPage.bounds [ 1 ] + docMargins.left,
docPage.bounds [ 2 ] - docMargins.bottom,
docPage.bounds [ 3 ] - docMargins.right, ],
actionsTextFrame = newDoc.pages [ 0 ].textFrames.add ( { geometricBounds : actionsTextFrameBounds } ),
actionsTable = actionsTextFrame.insertionPoints [ 0 ].tables.add ( { columnCount : 3, bodyRowCount : menuActionsLength } ),
i = 0;
for ( i ; i < menuActionsLength ; i++ )
menuActionsList.push ( menuActions [ i ].name.toString () ),
menuActionsList.push ( menuActions [ i ].area.toString () ),
menuActionsList.push ( menuActions [ i ].id.toString () );
actionsTable.contents = menuActionsList;
--
Marijan (tomaxxi)
North America
Europe, Middle East and Africa
Asia Pacific