PDA

View Full Version : How to center text in applescript


efuchs
2008-03-09, 08:34 AM
These work fine:

set size of self to 9
set text placement of self to top

Why doesn't this work?????:

set alignment of self to center

There aren't words for how frustrated I am right now.

kenfromboston
2008-03-13, 08:36 PM
Hi,

From what I've seen, the text alignment property is a property of the container, not the text itself. This sample code creates a rectangle with centered text inside:

tell document myDocumentName of application "OmniGraffle Professional 4"

make new shape at end of graphics of first canvas with properties {origin:{10, 10}, size:{200, 200}, draws shadow:false, draws stroke:true, name:"Rectangle", fill color:{65535, 65535, 65535}, text:{font:"Arial", size:10, alignment:center, text:"Hello!"}}
end tell

Hope this helps,

Ken

efuchs
2008-03-14, 04:19 AM
Hi Ken,
Thanks for the help.
I know how to create a new shape with centered text. What I am trying to do, however, is center the text of an already existing shape.
TIA,
Evan