View Single Post
Quote:
Originally Posted by RobTrew View Post
Thus, to search and replace text formatting properties:

Code:
-- Search and replace formatting properties
tell application id "OGfl"
	tell front window
		tell its canvas
			set oShape to item 1 of shapes
			
			set refText to a reference to text of oShape
			tell refText
				-- change anything redder to green
				repeat with oRun in attribute runs
					set {lngR, lngG, lngB} to color of oRun
					if (lngR > lngG and lngR > lngB) then set color of oRun to {0, 65535, 0}
				end repeat
			end tell
		end tell
		
		set zoom to zoom * 0.99
		refText
	end tell
end tell
and to simply list them:
Code:
-- List formatting properties
tell application id "OGfl"
	tell front window
		tell its canvas
			set oShape to item 1 of shapes
			
			tell text of oShape -- still an uncoerced reference
				set lstProps to properties of attribute runs
			end tell
		end tell
	end tell
end tell
--
Hi Rob,

I ran into this very thing today.

I came up with the following solution: not as flexible as yours - you'd need to set a property for each text-style you want to use - but it works in my situation, and it's not very much code.

(I didn't read the whole thread - apologies if someone earlier offered this.)

-- create a list of all desired text properties EXCEPT for its text property:

property _labelTextProperties: {size:_fontSize, color:{1, 1, 1}}

-- to create an object with a caption using the style above:

set _label to make new shape at end of graphics with properties {text: _labelTextProperties & {text: _labelText}, [other object properties]}

-- to change the text of (the text of) the object:

set text of _label to _labelTextProperties & {text: _newLabelText}