Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/FireMonkey/Dialogs    [ Add a report in this area ]  
Report #:  99840   Status: Open
TOpenDialog implementation always allows the user to choose a directory and not just a file on OS X
Project:  Delphi Build #:  16.0.4276.44006
Version:    16.1 Submitted By:   Chris Rolliston
Report Type:  Basic functionality failure Date Reported:  10/9/2011 6:28:14 PM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All Mac platforms Internal Tracking #:   288083
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 22
Description
In line 2630 of FMX.Platform.Mac.pas, the setCanChooseDirectories method is called, passing True as its parameter. This causes the resulting dialog to allow choosing a directory instead of only a file. This is inconsistent with the behaviour on Windows.
Steps to Reproduce:
1. Drop a TOpenDialog and TButton on a form.
2. Enable the foFileMustExist option in the dialog.
3. Set the button to show the dialog on being clicked
4. Target for the Mac, run the application, and click the button.
5. Select a directory and click Open.
6. The dialog closes, returning the path to the selected directory in its FileName property. This is unexpected.

Really, I think it was a mistake to promote the VCL TOpenOptions set to be a FireMonkey set too - instead, the TFileDialogOptions type (used by the VCL TFileOpenDialog component) is a better fit. Aside from TOpenOptions including legacy elements irrelevant in a FireMonkey context, TFileDialogOption includes a fdoPickFolders bit which would directly map to setCanChooseDirectories(True)/setCanChooseFiles(False) if set, and setCanChooseDirectories(False)/setCanChooseFiles(True) if not.
Workarounds
None
Attachment
None
Comments

Graham Neden-Watts at 11/3/2011 3:28:41 PM -
As an extension to this issue - In general we need a way in FMX to select folders as well as file open/save. Many apps require users to select a folder for data storage. In FMX, developers will need to implement a per-platform solution for this which seems a shame as Delphi clearly has the code in place to allow folder selection as well as file open/save

Server Response from: ETNACODE01