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.
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