• 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
why doesn't this 'objectForKey()' work, please?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why doesn't this 'objectForKey()' work, please?


  • Subject: why doesn't this 'objectForKey()' work, please?
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 23 Sep 2014 10:02:52 +1000

G'day scripters

I'm at a loss to explain this  one!  I'm trying to alter the NSColor of each character in a range, and cannot read the NSFont value to replace the old Attributes. 

What am I  doing wrong please?

Regards 

Santa

if lineFeedFlag and my flashTheMessage then
set textStorage to mainMessagesView's textStorage()
set textStorageString to mainMessagesView's |string|() as text
set theTotal to (count of textStorageString) - 1 as integer
set theRange to (count of textStorageString's paragraphs) as integer
set theOffset to (count of paragraph (theRange - 1) of textStorageString) as integer
#
set someColor to my matchAColor("Orange Red")
#
try
#
set p to 1
set {someColor} to my matchAColor("Fire Brick")
repeat with x from 1 to 4
set p to 1.4
repeat with x from (theTotal - theOffset - 1) as integer to (theTotal - 1) as integer
set p to 1.5
set itemForAttributes to textStorage's attributesAtIndex_effectiveRange_(x, {0, 0})
set p to 1.6
#tell itemForAttributes to set nowReadKeys to itemForAttributes's allKeys() # <== 'NSFont','NSColor'
set p to 1.7
  #
# Fails on both of these
#
set myFont to itemForAttributes's NSFont's valueForKey() #  <--- NSFont, doesn't work
set myFont to itemForAttributes's NSFont's objectForKey() #  <--- NSFont, doesn't work
set p to 1.8
set attrsDict to current application's NSDictionary's dictionaryWithObjects_forKeys_({myFont, someColor}, {current application's NSFontAttributeName, current application's NSForegroundColorAttributeName})
set p to 1.9
tell textStorage to setAttributes_range_(attrsDict, {x, 1})
end repeat
set p to 2
tell mainMessagesView to display()
tell current application to delay 0.4
set p to 3
tell textStorage to deleteCharactersInRange_({(theTotal - theOffset - 1) as integer, theOffset as integer})
tell textStorage to insertAttributedString_atIndex_(tempStorage, (theTotal - theOffset) as integer)
set p to 4
tell mainMessagesView to display()
set p to 5
tell current application to delay 0.3
end repeat
on error errmsg
display dialog "repeat loop " & errmsg & "   x =  " & x & "    p = " & p
end try
end if


 _______________________________________________
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: why doesn't this 'objectForKey()' work, please?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Requesting assistance with nomenclature
  • Next by Date: Re: why doesn't this 'objectForKey()' work, please?
  • Previous by thread: Requesting assistance with nomenclature
  • Next by thread: Re: why doesn't this 'objectForKey()' work, please?
  • Index(es):
    • Date
    • Thread