Cocoa: Font formatting popup buttons

476 views Asked by At

I am looking at a sample app that involves some text editing. It has some font formatting buttons like this:

enter image description here

I can't find where in the code these are being set up, which makes me think they come built in somehow. For example, the font popup button lists all fonts and has the most recently used fonts at the top.

I haven't been able to figure out how to achieve this by googling. How are these kinds of font buttons created?

EDIT: To clarify...my real goal is to create an app that has a text editing component. I want it to have text formatting buttons like this. So I'm not really interested in how it was done in this specific case; rather I want to know what the accepted method for achieving this is.

EDIT 2: Here's what I'm talking with the font button. It just seems to be happening magically:

enter image description here

EDIT 3: Here's another interesting thing. He's included images for the buttons in the project (like the bold icon and italic icon) but as far as I can tell these images are never used. So it's as if he found some other way to do it.

EDIT 4: Well now I've figured out that what I'm seeing is the NSTextView Inspector bar. Can anyone provide some help on how to position it?

2

There are 2 answers

0
James Harpe On BEST ANSWER

It turns out that what we are seeing here is the NSTextView inspector bar. Using NSToolbar, we were able to position it how we wanted it.

3
Jay On

Apart from the appearance - which uses some non-standard, dark scheme not available with standard Cocoa controls - it appears to be all standard OS X controls which you can simply configure yourself.

As for the dark appearance..
Apple has started to add something like styled controls with the NSAppearance class introduced in Mavericks, however from the current documentation it doesn't do much yet (10.9).

There are however quite a few third-party controls that mimic the controls found in Apple's Pro or iLife Apps. Examples are GPProKit or SNRHUDKit (amongst many others).