G'day Scripters
Thanks to Shane Stanley, I 'seem' to be able to retrieve the attributes of an Attributed text character; trouble is, how the heck do I actually check the value of keys contained in the Attribute?
I've spent all morning trying different things, without success. More damn frustration with lack of documentation.
Trying to find suitable methods on the net is like looking for needles in a haystack.
My method is below, and any guidance on how to actually read the r,g,b values from the attribute (and from an NSColor), greatly appreciated.
Regards
Santa
set itemForAttributesTemp to theVariedAttributedText's attributedSubstringFromRange_({1 as integer, 1 as integer}) # set itemForAttributes to itemForAttributesTemp's mutableCopy() set p to 1.4 # # The following two lines can be used to double-check that we've actually selected an alpha-numeric character, not a linefeed # set theItemAsString to itemForAttributes's |string|() #<= 'N' #display dialog theItemAsString as text # set p to 1.5 #set colorAccess to current application's NSForegroundColorAttributeName as text # <= 'NSColor' # # If you're using this Application to create your own version, then you can log # details using the following format # log (return & return & "itemForAttributes" & return & return as text) log (itemForAttributes) log (return & return as text) # # Courtesy of Shane Stanley # set myFontColor to itemForAttributes's attribute_atIndex_effectiveRange_(current application's NSForegroundColorAttributeName, 0, missing value) # say 10 try Need help with this…
set red1 to myFontColor's valueForKey(red) # data should be saved as keys, what key name? OR, do we need different approach? say 11 display dialog red1 as text end try say 12 #
and this…
# This is an NSColor. How do we find the r,g,b values? # set theCheckFromColorValues to theColor's valueForKey(red) the log…
2014-09-26 12:24:24.996 ApplescriptObjC Wizard[45903:303] [<NSCalibratedRGBColor 0x1005ec110> valueForUndefinedKey:]: this class is not key value coding-compliant for the key red.
|