Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Technical Q&A QA1485
How to create a Cocoa Disclosure Button Control

Q: How do I create a "disclosure button control" in Cocoa like the one found on the save dialog?

A: Even though disclosure button controls are not immediately available on an Interface Builder palette, they can still be created easily by changing the attributes of an ordinary NSButton of type "Disclosure". Instantiate a disclosure NSButton in your window's nib, create an outlet like 'disclosureButton' in an appropriate controller class. Connect the outlet to the NSButton.

In a nib-loading method such as -awakeFromNib or -windowControllerDidLoadNib in an NSDocumentController, send messages to set the bezel style of the control to NSDisclosureBezelStyle and the button type to NSPushOnPushOffButton.

Listing 1: Programatically Set the Bezel Style and Button Type

    [disclosureButton setBezelStyle: NSRoundedDisclosureBezelStyle];
    [disclosureButton setButtonType: NSPushOnPushOffButton];

For more information on disclosure controls, refer to "Controls > View Controls" section of the Apple Human Interface Guidelines, available at ADC Reference Library > User Experience > Fundamentals"

Document Revision History

DateNotes
2006-08-01First Version

Posted: 2006-08-01




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.