• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Got Attributes, do do I read the keys, please?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Got Attributes, do do I read the keys, please?


  • Subject: Got Attributes, do do I read the keys, please?
  • From: Brian Christmas <email@hidden>
  • Date: Fri, 26 Sep 2014 13:59:56 +1000

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.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Got Attributes, do do I read the keys, please?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Still cannot get CF terminology correct
  • Next by Date: Re: Got Attributes, do do I read the keys, please?
  • Previous by thread: Re: Cannot get terminology correct
  • Next by thread: Re: Got Attributes, do do I read the keys, please?
  • Index(es):
    • Date
    • Thread