NSOpenPanel can choose directories at runtime ?

I have searched but maybe not in the right place, however found absolutely nothing.


I have an NSOpenPanel with NSComboBox as Accessory View and want to select between either "Files Only" or "Include Folders" items in order to change canChooseDirectories at runtime ?

Replies

a. Don't use a combo box. It's a kind of text field. You want a kind of menu, so use NSPopUpButton.


b. Don't make the control the accessory view. Create a custom view which contains a (weak) reference to the panel, and the control as a subview (possibly with label text to explain, if warranted). Implement the action methods for your menu choices to change the panel's canChooseDirectories property.


It's a while since I've messed around with accessory views, but I think the panel will react to the change of canChooseDirectories property values.

Maybe you could get inspired by NSPrintPanelAccessorizing, to customize print panels.


But I have not tried with NSOpenPanel. And I feel KMT solution is the simplest and safest way to go.

Thanks for the replies.


This may be a cop out avoiding doing it programmatically but I didn't realize it was possible but in the Storyboard added an NSView object to my View Controller, ended up using a Check Box Button. This gave me ability not only to size and layout exactly what I wanted but then had access to a quick way to get the event creating an IB Action.