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.
  1. With the selection tool (black pointer), select the frame.
  2. In the Control palette, click the Select Contents button.
  3. Choose Edit/Cut, or use the keyboard shortcut for Cut.
But most users seem to take a long time to discover those selection buttons in the Control palette. They also seem to be unaware of the equivalent functionality on the Select submenu of the Object menu. And so, if they're familiar with FreeHand, they search in vain for the Cut Contents command.

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 Contents

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")
  }
}
I 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.

Comments:
AMEN, I loved cut contents. It took me a few minutes, but this worked FINALLY. Thank you.
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?