PDA

View Full Version : How to embed a control in a Dialog box?




Tortoise001
May 15, 2008, 12:58 AM
Hi,
I have used Window's MFC to embed controls like comboBox, pushBottons to a Modal dialog box, I am wondering how similar things can be done with XCode and Cocoa, I am very new to Mac GUI programming, I need some directions as to where to start...
E.g. In Windows, I first create a placeholder (picture frame) in Dialog Box using resource editor (similar to Mac's interface builder), then I wrote code to create controls using that placeholder ID. Are there similar concepts in Mac?
Thanks a lot...



Krevnik
May 15, 2008, 02:10 AM
How modal is modal? Is this like a "This application failed" modal, or "This document needs to do something" modal?

On OS X you have two levels of modal. Sheets (usually recommended) are modal for a particular window, usually a document or the main app window if you aren't document-based. Then you have application modal windows.

In OS X, a dialog is simply a window (if they are application modal), a sheet is usually a panel. You can add this to your UI in interface builder, and lay out the sheet or window like any other window. There are a couple APIs that let you setup a window to run as modal in Cocoa.

Application Modal:
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/NSApplication/runModalForWindow:

Window Modal (Sheet):
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/NSApplication/beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: