Like create a Font Menu as in Microsoft Word in my Mac OSX Cocoa Application

234 views Asked by At

I am Trying to Create a NSComboBox like the image attached with the list of Fonts. Any body knows and custom special control is available.

I have kept the image in dropbox

2

There are 2 answers

0
CRD On

I see you're new to SO. You say "I'm trying to create", what have you tried? In general on SO you should show what you've attempted, what did not work, what piece of information eluded you, etc.

Here's some information to get you started:

  • NSComboBox justs takes "objects" and says it will display "common value classes" (ref). Have you tried NSAttributedString?

  • NSFontManager has a method availableFonts

You can use those to quickly produce a menu of styled font names, it probably won't be what you want but it will be a start.

Note that on a Mac the recommended ways to select fonts are standard Font menus and the Font Panel (NSFontPanel), do you really want to mimic a Windows UI for a Mac app?

HTH

0
Sentry.co On

Swift 5.0

let fonts = NSFontManager.sharedFontManager().availableFonts();
//Then add this array to an NSComboBox component, programtatically or via XCode-Interface-builder