Adobe 23101335 Scripting Guide - Page 65

Setting the contents of the text item, textLayerRef.TextItem.Contents = Hello

Page 65 highlights

Scripting Photoshop 3 Text item object JS: docRef.artLayers["my text"].textItem.justification = Justification.RIGHT; IMPORTANT: The text item object has a kind property, which can be set to either point text (psPointText/TextType.POINTTEXT) or paragraph text (psParagraphText/TextType.PARAGRAPHTEXT). When a new text item is created, its kind property is automatically set to point text. The text item properties height, width and leading are only valid when the text item's kind property is set to paragraph text. 3.10.1 Setting the contents of the text item To set the contents of a text item in AppleScript you would write: set contents of text item of art layer "Layer 1" of ¬ current document to "Hello" If you use a text item object reference to set the contents you will need to write: set contents of contents of textItemRef to "Hello" The second "contents of" is needed because "contents" is a keyword which tells AppleScript to operate on the contents of the variable, rather than on the object to which it may refer. This means that AppleScript sees the above line as: set text item of art layer 1 of document "Untitled-1" ¬ to "Hello" To set the contents using references in VB and JS, write the following: VB: textLayerRef.TextItem.Contents = "Hello" JS: textLayerRef.textItem.contents = "Hello"; Photoshop 7.0 Scripting Guide 65

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91

Photoshop 7.0 Scripting Guide
65
Scripting Photoshop
Text item object
3
JS:
docRef.artLayers["my text"].textItem.justification =
Justification.RIGHT;
IMPORTANT:
The
text item
object has a
kind
property, which can be set to either
point
text (psPointText/TextType.POINTTEXT
) or
paragraph text
(psParagraphText/TextType.PARAGRAPHTEXT
). When a new
text
item
is created, its
kind
property is automatically set to
point text
.
The
text item
properties
height, width
and
leading
are only valid
when the text item's kind property is set to
paragraph text.
3.10.1 Setting the contents of the text item
To set the contents of a text item in AppleScript you would write:
set contents of text item of art layer "Layer 1" of ¬
current document to "Hello"
If you use a text item object reference to set the contents you will need to write:
set contents of contents of textItemRef to "Hello"
The second “contents of” is needed because “contents” is a keyword which tells AppleScript
to operate on the contents of the variable, rather than on the object to which it may refer. This
means that AppleScript sees the above line as:
set text item of art layer 1 of document "Untitled-1" ¬
to "Hello"
To set the contents using references in VB and JS, write the following:
VB:
textLayerRef.TextItem.Contents = "Hello"
JS:
textLayerRef.textItem.contents = "Hello";