3

Usually, I use SHBrowseForFolder to support browsing for a folder... but I want to support both Windows and OSX.

I looked at:

  • System.IOUtils but didn't find any relevant function (maybe, I missed one?)
  • TOpenDialog options but didn't find one to pick a folder instead of a file...

Any idea? (I can manage ifdef for Windows but I have no clue for the Mac part...)

Cheers,

W.

Argalatyr
  • 4,639
  • 3
  • 36
  • 62
Whiler
  • 7,998
  • 4
  • 32
  • 56
  • When you do find the answer, try not to use ifdef if you can avoid it. It's much nicer to have a single interface and make two different code files. You could name them os-support-win32 and os-support-osx, or windows-folders, osx-folders, etc. Then use the right one in the project depending on operating system. Makes the code nice to read. – Zan Lynx Nov 04 '11 at 20:11
  • Ok.. I'll try ;o) Good suggestion! – Whiler Nov 04 '11 at 20:32

1 Answers1

6

Try using the NSOpenPanel class, Jeremy North publish a sample a few weeks ago SelectDirectory for OS X.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • It does exactly what I want... FYI, the `uses` I added: `MacApi.AppKit, MacApi.Foundation, Macapi.CocoaTypes` – Whiler Nov 04 '11 at 21:18
  • 1
    Also you can see a sample of use of this class in the `TPlatformCocoa.DialogOpenFiles` function in the FMX.Platform.Mac unit. – RRUZ Nov 04 '11 at 21:21