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 Today's Posts

 
Toggling (cycling) the color of text nodes Thread Tools Search this Thread Display Modes
The nodes in my diagrams tend to be either gray, black, or red text.

By assigning this script to a keystroke with something like Keyboard Maestro or FastScripts, I can select a shape, and toggle the color of its text between black, gray, red.

Code:
property plstBlack : {0, 0, 0}
property plstGray : {32767, 32767, 32767}
property plstRed : {65534, 0, 0}

tell application id "com.omnigroup.OmniGrafflePro"
	try
		set lstSeln to selection of front window
	on error
		return
	end try
	if lstSeln = {} then return
	
	tell (first item of lstSeln)
		if its text ≠ "" then
			tell its text
				set lstColor to its color
				
				if lstColor = plstGray then
					set its color to plstRed
				else if lstColor = plstBlack then
					set its color to plstGray
				else
					set its color to plstBlack
				end if
			end tell
		end if
	end tell
end tell
--

Last edited by RobTrew; 2011-03-01 at 02:39 PM..
 
Or, to toggle the text color of all selected shapes together, something like:

Code:
property plstBlack : {0, 0, 0}
property plstGray : {32767, 32767, 32767}
property plstRed : {65534, 0, 0}

tell application id "com.omnigroup.OmniGrafflePro"
	try
		set lstSeln to selection of front window
	on error
		return
	end try
	set lngSelns to count of lstSeln
	if lngSelns < 1 then return
	
	-- FIND THE FIRST SHAPE IN THE SELECTION WHICH HAS TEXT (IGNORE LINES)
	set blnFound to false
	repeat with oSeln in lstSeln
		if (class of oSeln = shape) and (text of oSeln ≠ "") then
			set blnFound to true
			exit repeat
		end if
	end repeat
	
	if blnFound then
		-- GET THE NEXT COLOR IN THE SEQUENCE
		tell (text of oSeln)
			set lstColor to its color
			if lstColor = plstGray then
				set lstNewColor to plstRed
			else if lstColor = plstBlack then
				set lstNewColor to plstGray
			else
				set lstNewColor to plstBlack
			end if
		end tell
		
		-- AND APPLY THE NEW COLOR TO ALL SELECTED SHAPES
		repeat with oSeln in lstSeln
			if (class of oSeln = shape) and (text of oSeln ≠ "") then set color of text of oSeln to lstNewColor
		end repeat
	end if
end tell

Last edited by RobTrew; 2011-03-01 at 02:36 PM..
 
Amended both examples above to allow for shapes which contain no text.

(Thanks to Whpalmer4 for spotting that issue).
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
Color Highlight for Found Text Scott Betz OmniOutliner 3 for Mac 1 2012-03-19 02:07 PM
Text background color in OGfl - a singular torpor RobTrew OmniGraffle General 1 2011-09-26 04:36 AM
9 steps to change text color? kknorpp001 OmniOutliner for iPad 3 2011-09-19 12:16 PM
Toggling color of selected rows between 2 or more colors RobTrew OmniOutliner 3 for Mac 1 2011-03-01 02:20 PM
How do I change background/text color, fonts, and styles? [Colour] gruber OmniFocus 1 for Mac 26 2010-06-09 03:21 AM


All times are GMT -8. The time now is 04:59 PM.


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