Skip to content

Instantly share code, notes, and snippets.

@leonlihkust
leonlihkust / GetSelectedId
Created August 27, 2014 01:17
Get selected text frame or image id in InDesign document
public function GetSelectedObjectID():String
{
var objectId:String = "";
if(InDesign.app.selection[0] != null)
{
if(InDesign.app.activeDocument.selection[0] is TextFrame)
{
var textObject:TextFrame = InDesign.app.selection[0];
objectId = textObject.id.toString();
}
@leonlihkust
leonlihkust / TextRestrictionInDesign
Created August 19, 2014 09:42
Add restriction to text box InDesign
var textRestrict:spark.components.TextInput;
textRestrict.restrict = "0-9," //Numbers and comma only
/*********************************************************
textRestrict.maxChars = 5;
textRestrict.restrict = "a-zA-Z0-9"; //Alpha-numeric only
textRestrict.restrict = "0-9"; //Numbers only
textRestrict.restrict = "^a-z"; //All chars, only uppercase alpha
textRestrict.restrict = "\u0020-\u007E"; //ASCII chars 32 (space) through 126 (tilde) only
textRestrict.restrict = "^\^\-"; //All chars but not the caret or hyphen