The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Scripting text alignment - Peter Pan effect Thread Tools Search this Thread Display Modes
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:
  1. Setting a starting zoom level (say 85%),
  2. running the alignment-toggling script once,
  3. manually changing the zoom level to 100%,
  4. then manually changing it back to 85% ...



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
Attached Thumbnails
Click image for larger version

Name:	Screen shot 2012-01-07 at 10.26.45.png
Views:	531
Size:	81.7 KB
ID:	2212  

Last edited by RobTrew; 2012-01-07 at 11:13 AM.. Reason: Added steps for reproducing the effect. Sadly it doesn't print - but there is always screen dump ...
 
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

Last edited by RobTrew; 2012-01-07 at 10:51 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default text alignment perfectmacsolutions OmniGraffle General 4 2010-08-24 10:42 AM
the action “halo effect” bigcloits Applying OmniFocus 14 2009-08-15 06:24 PM
Text Alignment Default? tmeehan OmniGraffle General 4 2008-03-06 04:40 PM
Setting Due Date - No Effect Hawkcode OmniFocus 1 for Mac 5 2007-07-28 12:25 PM
Object reflection effect hardcoreUFO OmniGraffle General 3 2007-07-23 02:15 PM


All times are GMT -8. The time now is 11:10 AM.


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