• 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
Re: Requesting help with setting size of text, please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Requesting help with setting size of text, please


  • Subject: Re: Requesting help with setting size of text, please
  • From: Ron <email@hidden>
  • Date: Mon, 10 Aug 2015 10:25:34 -0500

Brian,
This compiles and works for me. 

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 redRange to {9,3}

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

—

The log command above prints out:

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


On Aug 10, 2015, at 7:02 AM, Brian Christmas <email@hidden> wrote:

(Sigh) Shane, while I thank you greatly for your help, will you please remember I’m as dumb a s**t when it comes to deciphering what you write.

I haven’t got the foggiest on what variables to plug in, in…

set setBoldFont to (current application's NSFont's boldSystemFontOfSize:13)
# (attributedSearchItem's addAttribute:myFont value:setBoldFont range:attributeRange)
# (attributedSearchItem's addAttribute:setBoldFont value:13 range:attributeRange)
(attributedSearchItem's addAttribute:(current application's NSFont) value:setBoldFont range:attributeRange)

And I’ve already tried 42 different permutations of previous attempts at getting the code right, with no idea of what I was doing.

And they don’t error to give me any clues.

Regards

Santa

 _______________________________________________
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: Requesting help with setting size of text, please
      • From: Ron <email@hidden>
References: 
 >Requesting help with setting size of text, please (From: Brian Christmas <email@hidden>)
 >Re: Requesting help with setting size of text, please (From: Shane Stanley <email@hidden>)
 >Re: Requesting help with setting size of text, please (From: Brian Christmas <email@hidden>)
 >Re: Requesting help with setting size of text, please (From: Shane Stanley <email@hidden>)
 >Re: Requesting help with setting size of text, please (From: Brian Christmas <email@hidden>)
 >Re: Requesting help with setting size of text, please (From: Shane Stanley <email@hidden>)
 >Re: Requesting help with setting size of text, please (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Requesting help with setting size of text, please
  • Next by Date: Re: Requesting help with setting size of text, please
  • Previous by thread: Re: Requesting help with setting size of text, please
  • Next by thread: Re: Requesting help with setting size of text, please
  • Index(es):
    • Date
    • Thread