Open Dialog confusion

I’d like to user to select a folder or file, or several of each, in an open dialog. But which open dialog shall I use? With OpenFileDialog the folders are unselectable, FolderitemDialog does not work, SelectFolderDialog seems not to get files as well…
Any suggestion?

Are-you able to do that with a software, any software ?

If the answer is no, chances are that it is not possible.

But I may be wrong (even if I never saw that in the last 40 years of computer use).

Nota: SelectFolderDialog allow you to choose a Folder; then you can scan every object it holds (files AND folders). This can be your answer, if you populate a ListBox and let your user choose the items he needs…

Yes, in the Finder I can e.g. in the Documents folder select folders and text files, then hit cmd-O, and all folder and files open… :slight_smile:

That is the only example I know, but the result is totally different (and so the purpose).

You are not writing another Finder, aren’t you ?

What about my ListBox suggestion ?

Well, Emile, how do you know what my purpose is?
But I tell you: what ever file or folder the user selects, I want to add or remove something to or from the file name.
So with your method, I simply would take by default the whole hard disk folder, and then create a Finder-like listbox of the whole file tree? (Which is as you call it ‘another Finder’, to be able to use cmd-O). But my question is: why are the current dialogs limited in doing that, after all the Finder does it easily!?
Obviously, Xojo seems not to be as capable as the Finder, or rather, prohibits even to do the same!
Maybe Christian from MBS has a solutuion at hand (as always)?

And the Finder isn’t as capable as Xojo, because they’re applications written for different purposes.

Look at the “File Browser” example (Examples/Files/FileBrowser) to see a basic way to start. You’d have to make it capable of selecting multiple files, and make it look more like a regular dialog window, but it’s a start.

Thanks for the tip; but it is really basic, and not what I am looking for. Also, my program shall be able for drag and drop folders and files to open at the same time…
I’ll put in a feature request, hope to get a more practical solution with the support of Xojo.

Just found: E.g. a feature request from 2008 (#2672) handled this already, same suggestion to make a custom listbox… And it seems to have been fixed, but obviously it’s not.
Or #4087, and nothing happened as well…
Why is this not implemented still??

Hi Peter. What you’re requesting isn’t something that the OS provides, really. It’s generally one or the other. Files or Folders. The custom listbox route is not only the way to do it in Xojo, but in many other development platforms as well.

Of course, you can do a dialog for selecting files AND folders with the MBS plugin.

Well, if you read the TITLE and the request itself it says allow Multiple FILES, not folders.

Selecting multiple files is ALREADY implemented since 2010r4. What you mean with “obviously it’s not”?

This is almost certain that it will not happen. Selecting files AND folders is not the standar OS behavior for all desktop targets. For this to happen Xojo have to make a custom dialog but if this feature is going to be used only for a few users… maybe their time is better in other things.

If you want a custom behavior, make a custom dialog, r use MBS.

This is technically possible as it is provided as part of the macOS (at least).

As it currently stands you have to completely replace the Xojo OpenDialog with either code from the Ohanaware App Kit (written by me) or use t’other MBS plugin.

App Wrapper uses this in its “Add Files” section of “Bundle Contents”.

Dim nod as new NSOpenPanel
nod.canChooseFiles          = true
nod.canChooseDirectories    = true
nod.allowsMultipleSelection = true
nod.promptText              = "Select files or folders to import into this application"

nod.showWithin( self, addressOf selectedFilesToImport )

I have this feature request asking Xojo to expose the means for us to access the underlying NSSavePanel (IIRC NSOpenPanel is a subclass of the NSSavePanel). feedback://showreport?report_id=30959

If this feature request was implemented, you could have this functionality with just a couple of extra lines of code.

The Finder is a whole application. Open dialogs are… well, dialogs. They aren’t supposed to work the same.

1 Like

Here’s a screen grab… Is this what you’re after?

1 Like

Lovely! Thanks, Sam.
Need to check-out MBS possibilities, too, as a current happy MBS customer.
Can’t understand why some are making a religion out it, because this is just a Xojo inability which could be easily solved / enhanced, and nobody would be harmed.

Guessing (as I’m not privy as to what goes on behind the scenes at Xojo), I would imagine that in this case they’re NOT actually creating the NSOpenPanel until showModal is being called. At which point it is too late to allow customization, in order to change the way it works would require refactoring the class and it has probably been deemed not worth it, when only a couple of developers have wanted this functionality and there are 3rd Party alternatives available.

But glad that it has given you pointers on how to solve it :slight_smile:

@Peter_Kronenberg
You are in this Forum since Dec 2001; you know how things runs.

Usually, when the feature does not exists in Xojo, you have to either use declare or plugins.

Feature request is a time consuming route (usually) while a plugin or a workaround will be faster.

Now, you have the choice.

Isn’t that you who wrote:

? Even thought the navigation dialog on Mac allows selecting folders and files (at the same time) since at least Mac OS 8.1 :wink:

While this is currently true, future users or needs would benefit of having the function built-in.

So guys, I took to easy route and implemented another MBS command (thanks Christian):

’ prep and show dialog
o = new OpenDialogMBS
o.WindowTitle = “Choose Data”
o.PromptText = “Please select folder(s) or file(s) where names have to be changed…”
o.ActionButtonLabel = “Select”
o.CancelButtonLabel = “Cancel”
o.CustomPicture = stars
o.AllowFolderSelection = true ’ yes!
o.MultipleSelection = true ’ yes!
o.ShowHiddenFiles = true
o.ShowDialog

It works, and I’m happy enough.
Thread closed.

2 Likes

No, the Finder do not do it with Dialog…

o.PromptText = “Please select folder(s) or file(s) where names have to be changed…”
Are-you aware that the Finder allows you to make changes to items (files and folders) names ?
(change part, add prefix/suffix, set name and indexed numbers…).

Well, Emile, how do you know what my purpose is?
I do not knew just because you do not disclosed that, then.

You have a solution and I am happy.

While I was driving, I recall that my suggestion was… too simple:
you could create your “own Dialog” window with a ListBiox and some buttons.
ListBox:
Column(0) Item Icon
Column(1) Item Name
Column(2) Whatever you need

Buttons:
Open, Close, Accept: whatever you need.

You also could use real drag and drop into your window, and I suppose (I do not checked) files and folders can be dragged at the same time…

But not knowing what you wanted to do with the OS objects restricted the answers possibilities.

1 Like