• 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: Trying to set pop-up button list of fonts to attributed font names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to set pop-up button list of fonts to attributed font names


  • Subject: Re: Trying to set pop-up button list of fonts to attributed font names
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 02 Oct 2014 22:29:39 +1000

On 2 Oct 2014, at 10:12 pm, Brian Christmas <email@hidden> wrote:

Shane, in answer to your question 'perhaps a prayer' you're correct, mainly because I still don't know what I'm doing with translating the vagaries of Apple's documentation to ASOC, and I'm still bloody praying, cause your esoteric answer went nowhere in me resolving my coding inabilities. And it's not enough of a clue as well.

Well the code you're posting now suggests you can see the problem with what you posted, and what I was alluding to. Now you have:

my fontButton's |menu|()'s addItemWithTitle_action_keyEquivalent_("", "changeTheFont:", "")
 #
# I'd already tried this, but it doesn't work.
#
my fontButton's |menu|()'s last item's setAttributedTitle_(eachAttributedFontString as text)

So you're calling the method on *something*, and you know it should be a menu item. But "last item" is hardly going to work, because that's for AppleScript lists, not NSMenus. So the question becomes: what method of NSMenu will return you its last menu item? And there isn't one, directly, but there are several that return menu items. Your choice becomes: (a) use itemAtIndex: and keep count so you know the index, (b) use itemAtIndex: and call numberOfItems every time, which is probably going to slow things down, or (c) do something creative like make your menu item with a placeholder title, and use itemWithTitle:. The latter will work, because you're going to effectively overwrite the title each time.

An alternative is to create the menu item first, using alloc and initWithTitle:action:keyEquivalent:, set its attributed title, and add it to the menu using NSMenu's addItem: method.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: Trying to set pop-up button list of fonts to attributed font names
      • From: Brian Christmas <email@hidden>
References: 
 >Trying to set pop-up button list of fonts to attributed font names (From: Brian Christmas <email@hidden>)
 >Re: Trying to set pop-up button list of fonts to attributed font names (From: Shane Stanley <email@hidden>)
 >Re: Trying to set pop-up button list of fonts to attributed font names (From: Brian Christmas <email@hidden>)
 >Re: Trying to set pop-up button list of fonts to attributed font names (From: Shane Stanley <email@hidden>)
 >Re: Trying to set pop-up button list of fonts to attributed font names (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Trying to set pop-up button list of fonts to attributed font names
  • Next by Date: Re: Trying to set pop-up button list of fonts to attributed font names
  • Previous by thread: Re: Trying to set pop-up button list of fonts to attributed font names
  • Next by thread: Re: Trying to set pop-up button list of fonts to attributed font names
  • Index(es):
    • Date
    • Thread