The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Scripting text alignment - Peter Pan effect (http://forums.omnigroup.com/showthread.php?t=23152)

RobTrew 2012-01-07 01:42 AM

Scripting text alignment - Peter Pan effect
 
1 Attachment(s)
The alignment of text in OG shapes can be changed by script (code below), but the screen display is not updated until the file is closed and reloaded, or, less reliably, the zoom level is changed.

Oddly, different levels of zoom show different stages of update. At 85% on my system, I am seeing a curious Peter Pan effect, in which the text has moved, but has left its shadow behind ...

In case the effect looks useful, you should be able to reproduce it by:[LIST=1][*]Setting a starting zoom level (say 85%),[*]running the alignment-toggling script once,[*]manually changing the zoom level to 100%,[*]then manually changing it back to 85% ...[/LIST]
[IMG]http://forums.omnigroup.com/attachment.php?attachmentid=2212&stc=1&d=1325932730[/IMG]

[CODE]tell application id "OGfl"
tell front canvas of front document
set refRuns to a reference to attribute runs of text of shapes
set lstAlign to alignment of refRuns
if first item of lstAlign = {left} then
set alignment of refRuns to right
else
set alignment of refRuns to left
end if
alignment of refRuns
end tell
end tell[/CODE]

RobTrew 2012-01-07 10:48 AM

A workaround seems to be to force a screen update with a tiny scripted change to zoom level.

(Though the original zoom level continues to show the wrong state of play until a save, close and reload).

[CODE]tell application id "OGfl"
activate

tell front window
tell its canvas
set refRuns to a reference to attribute runs of text of shapes
set lstAlign to alignment of refRuns

set eAlign to first item of first item of lstAlign
if eAlign = left then
set alignment of refRuns to center
else if eAlign = center then
set alignment of refRuns to right
else
set alignment of refRuns to left
end if
end tell

-- FORCE A REPAINT
set zoom to zoom * 0.999
end tell
activate
end tell[/CODE]


All times are GMT -8. The time now is 05:54 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.