3 Replies
      Latest reply on Apr 13, 2019 11:52 AM by Pendragon
      Pendragon Level 1 Level 1 (0 points)

        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 ?

        • Re: NSOpenPanel can choose directories at runtime ?
          QuinceyMorris Level 8 Level 8 (5,980 points)

          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.

          • Re: NSOpenPanel can choose directories at runtime ?
            Claude31 Level 8 Level 8 (5,775 points)

            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.

            • Re: NSOpenPanel can choose directories at runtime ?
              Pendragon Level 1 Level 1 (0 points)

              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.