Friday, December 22, 2006
Cut Contents
Every now and then a FreeHand user will pine for its Cut Contents command. This allows FreeHand users to select a frame that is serving as a mask by virtue of a previous Paste Into command. InDesign's user interface actually makes this fairly easy to achieve.
The topic came up again this morning on the U2U forum where I posted a simpler version of the script below. See: http://adobeforums.com/cgi-bin/webx?14@@.3bc2a49a/3
As you can see in that posting, I immediately realized there was a problem if the user ran that version of the script with text selected. As the day wore on, I realized that groups and xmlElements also are problematic, so I ended up with this version of the script:
- With the selection tool (black pointer), select the frame.
- In the Control palette, click the Select Contents button.
- Choose Edit/Cut, or use the keyboard shortcut for Cut.
The topic came up again this morning on the U2U forum where I posted a simpler version of the script below. See: http://adobeforums.com/cgi-bin/webx?14@@.3bc2a49a/3
As you can see in that posting, I immediately realized there was a problem if the user ran that version of the script with text selected. As the day wore on, I realized that groups and xmlElements also are problematic, so I ended up with this version of the script:
//DESCRIPTION: Cut ContentsI keep telling myself that one of these days I'll script the equivalent of FreeHand's Attach Type to Path command, particularly the variation where a two-line text is attached to the top and bottom of an ellipse.
Object.prototype.isIneligible = function() {
switch(this.constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "TextFrame":
case "Group" :
case "XMLElement" :
return true;
default :
return false;
}
}
if (app.documents.length == 0 || app.selection.length != 1 || app.selection[0].isIneligible()) { exit() }
processSelection(app.selection[0]);
function processSelection(sel) {
try {
app.select(sel.pageItems[0])
app.cut(); } catch(e) {
alert("Selected item has no contents")
}
}