Article View: adobe.photoshop.scripting
Article #521Re: Cancel User Action
From: xbytor
Date: Mon, 05 Jan 2009 18:02
Date: Mon, 05 Jan 2009 18:02
47 lines
1967 bytes
1967 bytes
You can't 'cancel' an event that has already occurred. The best you can do is
'undo' it.
Here's some code for undo and redo. The lowercase versions traverse the history
list (from the History Palette). The uppercase versions are the same as
selecting 'Undo' and 'Redo' from the Edit menu.
There is currently no practical way of recording the Crop event for later
playback unless you actually invoke the Crop command from within your script.
-X
// extracted from xtools/xlib/stdlib.js
Stdlib = {};
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
Stdlib.doEvent = function(id) {
return app.executeAction(id, new ActionDescriptor(), DialogModes.NO);
};
Stdlib.hist = function(dir) {
function _ftn() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(cTID("HstS"), cTID("Ordn"), cTID(dir));
desc.putReference(cTID("null"), ref);
executeAction(cTID("slct"), desc, DialogModes.NO);
}
_ftn();
};
Stdlib.undo = function () {
Stdlib.hist("Prvs");
};
Stdlib.redo = function () {
Stdlib.hist("Nxt ");
};
Stdlib.Undo = function () {
Stdlib.doEvent(cTID("undo"));
};
Stdlib.Redo = function () {
Stdlib.doEvent(sTID('redo'));
};
Technical Details
Message-ID:
<58009F40244A623F29B20D9CE056D6A1@in.webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b76dab.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,b62f667ea8116244 X-Google-Attributes: gidf5839,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: xbytor@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Cancel User Action Message-ID: <58009F40244A623F29B20D9CE056D6A1@in.webcrossing.la2eafNXanI> Date: Mon, 5 Jan 2009 10:02:26 -0800 References: <59b76dab.-1@webcrossing.la2eafNXanI> Lines: 53 User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit