Open Dialog, both file and folder

Hi, how do I get an dialog box for choosing both File or Folder…

Right now I can only get one of them, but I need both, in order to differentiate later in the code…

i.e. the new FCPX has a library the is a bundle…: myLibrary.fcpbundle

This is a director, but in order to select it I need to do a open dialog for files and not folders…
If I choose a dialog for folders, then I can not select this library…
any hints

Or do I have to have two options, 1 for library and a second for folder with libraries inside

/Helge

On Mac this is possible.
e.g. with AllowFolderSelection property on OpenDialogMBS class.

OpenDialogMBS is not mac app store nice, as you say in your documentation, NSOpenPanelMBS instead ?

yes, NSOpenPanelMBS should work.

[quote=54057:@Helge Tjelta]This is a director, but in order to select it I need to do a open dialog for files and not folders…
If I choose a dialog for folders, then I can not select this library…
any hints[/quote]

You could use a drag and drop interface instead of the open dialog. When user drops an icon over your app it can be opened as file or directory. You have to manage multiple select as well.

Right now I can only get one of them, but I need both, in order to differentiate later in the code…
To know if the FolderItem is a Directory (Folder on OS X), use:

FolderItem.Directory

If f.Directory Then // It's a directory Else // It's a file End If

Get an eye there:
FolderItem

Hi Michel, I have 3 ways of getting my folder/files. Both drag|drop, shortCut for Open/and menu, and lastly via click into textfield…

But only drag|drop, gave me full control. The two others, I have to rely on dialogboxes and how they behave…

Lucky for me, MBS had a NSOpenDialog plug, that allowed me to both look for folder and files at the same time.

/Helge

Helge wrote

The two others, I have to rely on dialogboxes
No, you can open a file without displaying any dialog box at all…

Hi Emile, I know that, here the object was to give the user a choice. The user will choose which file or folder to open.

:slight_smile:

I am sorry: I do not get the point: how opening a folder is similar to open a file ?

Hi Emilie, it all started with Xojo openDialog boxes.

they insists on only file or folder, never both

yes Helge, I understand that, but, since I do not have FCP, I do not understand why you want to open a fcpbundle like if it is a folder. I do not have a .fcpbundle file, so I cannot understand the trouble.

You say it is a directory (and so you know) and you want to open it. So far, so good, but you do not say what in the bundle you want to open (and why do you want to allow the user to see what is in the Bundle 'cause Apple hide the contents from the user eyes).

If there is a way to open the file you want to open in the Bundle, let the user choose the bundle and do the job silently. So no folder to open (from the user point of view).

Please, explain if I am completely wrong.

Hi Emilie,

The finder (and Xojo), sees the bundle as a file and not a folder. But when that file is as an item in xojo, then is sees it as a folder, but the dialogbox does not. So here is my problem, the dialogbox sees it as a file, and xojo sees it as an object with f.directory true.

So there is a difference from the dialogbox and xojo code later.

The SelectFolderDialog gives folder. But when trying to choose a bundle, it is greyed out, because the dialogbox sees it as a file, though it is a folder.

If it do FolderItem, then I only get files, and can not select a folder with several libraries inside…

thats why I needed a solution for getting both folders and files in a dialogbox.

:slight_smile:

Excuse me jumping in, but if you are selecting a file in a folderopendialog from XOJO you can get the parent of the file you are selecting. If you are trying to find the names of the folders inside of the folder you would use recursion.

Yes, but then a user must choose a file in order to later decide to use the whole folder. I’ll give him the choice right away.

The best way to see it is to download the Final Cut Pro X Trial, make a librariy and try to select either the folder or the bundle.

:slight_smile:
BTW, Christian has updated his OpenDialogMBS to use NSPanels in background, so now I have two options that works.

Helge:

be cautious with what you see Apple doing in their applications. Sometimes they do not respect the rules they wrote elsewhere.

I am very astonished by what you want to let your user do. As you know, Apple’s Finder does not let you do that (unless you know you can use the ContextualMenu).

There is a pdf about bundles in developer.apple.com web site. Here’s one example (but there are more):
Cocoa Core Competencies

Now, this is only rethorical since you found two ways to achieve what you want to do.

Hi Emile, the user will not go into the bundle, the program does that for him, I only let him choose the bundle itself. Then I present him with some choices on what to do with the bundle…

BTW: here is the link to the previos version:

http://tiny.cc/1wr47w (version 1.5) is the old, and the new V 1.6 is set to automaticly release when it is ready.