script AppDelegate
property parent : class "NSObject"
property cFont : class "NSFont"
property cColor : class "NSColor"
-- IBOutlets
property theWindow : missing value
property txtfieldRed : missing value
on applicationDidFinishLaunching_(aNotification)
set txtfieldRed's stringValue to "There is RED in this field"
set attStr to txtfieldRed's attributedStringValue's mutableCopy
set rangeFont to cFont's boldSystemFontOfSize_(14)
set rangeColor to cColor's redColor
attStr's addAttribute_value_range_("NSFont", rangeFont, redRange)
attStr's addAttribute_value_range_("NSColor", rangeColor, redRange)
log attStr
set txtfieldRed's attributedStringValue to attStr
end
on applicationShouldTerminate_(sender)
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
2015-08-10 10:23:21.751 TestCocoaAppleScript[21726:3187658] There is {
NSColor = "NSNamedColorSpace System textColor";
NSFont = "\".HelveticaNeueDeskInterface-Regular 13.00 pt. P [] (0x600000a52180) fobj=0x6000001e6300, spc=3.94\"";
NSOriginalFont = "\".HelveticaNeueDeskInterface-Regular 13.00 pt. P [] (0x600000a52180) fobj=0x6000001e6300, spc=3.94\"";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 2, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0";
}RED{
NSColor = "NSCalibratedRGBColorSpace 1 0 0 1";
NSFont = "\".HelveticaNeueDeskInterface-Bold 14.00 pt. P [] (0x608000a489a0) fobj=0x6080001e8600, spc=4.15\"";
NSOriginalFont = "\".HelveticaNeueDeskInterface-Regular 13.00 pt. P [] (0x600000a52180) fobj=0x6000001e6300, spc=3.94\"";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 2, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0";
} in this field{
NSColor = "NSNamedColorSpace System textColor";
NSFont = "\".HelveticaNeueDeskInterface-Regular 13.00 pt. P [] (0x600000a52180) fobj=0x6000001e6300, spc=3.94\"";
NSOriginalFont = "\".HelveticaNeueDeskInterface-Regular 13.00 pt. P [] (0x600000a52180) fobj=0x6000001e6300, spc=3.94\"";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 2, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0";
}
SO you can see it is working.
— Ron