Wanting to go into .app bundles with File Dialogs (OpenFile, SaveFile, SelectDirectory), I modified the Dialogs a little bit and I'm sure others might have a use for this as well.
As an example: The "
Configure External Tools" in the
IDE will not allow you to select an executable that resides in an .APP bundle (needed to pass parameters).
Additionally wanted to add a title to the file dialogs, so there is that as well.
Would love to submit this, just not sure how to do it, and I'm sure someone more experienced may want to take a look at it first.
These changes add two options to
OptionsEx for OpenFileDialog, SaveFileDialog and SelectDirectoryDialog dialogs.
1)
ofMacOSAllowBrowseAppBundleAllows the user to browse into App bundles as if they were directories.
2)
ofMacOSUseAlternativeTitleDisplays a title (using the Title property of the file dialog), since setTitle() doesn't do anything as of macOS 10.15.
Since titles seem not often used in newer macOS versions, I figured this should be an option instead of a default.
Maybe I'm wrong 😉
Changes In /lcl/
dialogs.pp, around line 219 Added :
ofMacOSAllowBrowseAppBundle and
ofMacOSUseAlternativeTitle.
There are already quite a few OS specific options (XP and Vista), so why not add two for macOS.
TOpenOptionEx = (
ofHidePinnedPlaces, // Windows Vista+: Hide items shown by default in the view's navigation pane.
ofStrictFileTypes, // Windows Vista+: In the Save dialog, only allow the user to choose a file that has one of the file name extensions specified through Filter property.
ofPickFolders, // Windows Vista+: Turns the dialog into a TSelectDirectoryDialog.
ofOkButtonNeedsInteraction, // Windows Vista+: The OK button will be disabled until the user navigates the view or edits the filename (if applicable).
ofForceFileSystem, // Windows Vista+: Ensures that returned items are file system items.
ofAllNonStorageItems, // Windows Vista+: Enables the user to choose any item in the Shell namespace, not just those with SFGAO_STREAM or SFAGO_FILESYSTEM attributes. Flag cannot be combined with ofForceFileSystem.
ofUseXPStyleAsFallBack, // Windows Vista+: Use XP-style dialog if creating Vista-style dialog fails (e.g. when running under Windows Recovery).
ofMacOSAllowBrowseAppBundle,// macOS: All browsing .App bundles
ofMacOSUseAlternativeTitle // macOS: Display a title in the dialog window
// Intentionally not supported: ofDefaultNoMiniMode, ofHideMruPlaces: these values are not supported as of Windows 7.
);
And in /lcl/interfaces/cocoa/
cocoawsdialogs.pas added around 480 (TCocoaWSFileDialog.ShowModal)
openDlg.setTreatsFilePackagesAsDirectories(ofMacOSAllowBrowseAppBundle in TSelectDirectoryDialog(FileDialog).OptionsEx);
openDlg.setAccessoryView(nil);
if ofMacOSUseAlternativeTitle in TSelectDirectoryDialog(FileDialog).OptionsEx then
begin
openDlg.setMessage(NSSTR(FileDialog.Title)); // works macOS 10.15+
openDlg.setTitleVisibility(0);
end;
openDlg.setTreatsFilePackagesAsDirectories(ofMacOSAllowBrowseAppBundle in TOpenDialog(FileDialog).OptionsEx);
openDlg.setAccessoryView(nil);
if ofMacOSUseAlternativeTitle in TOpenDialog(FileDialog).OptionsEx then
begin
openDlg.setMessage(NSSTR(FileDialog.Title)); // works macOS 10.15+
openDlg.setTitleVisibility(0);
end;
saveDlg.setTreatsFilePackagesAsDirectories(ofMacOSAllowBrowseAppBundle in TSaveDialog(FileDialog).OptionsEx);
if ofMacOSUseAlternativeTitle in TSaveDialog(FileDialog).OptionsEx then
begin
openDlg.setMessage(NSSTR(FileDialog.Title)); // works macOS 10.15+
openDlg.setTitleVisibility(0);
end;
It was quite a pain to figure out how to even make a patch file (added "how to make a patch for uncommitted changes" to the
Wiki page), and I'm not even sure I did this the right way.
So any input/assistance would be greatly appreciated.
Attached the patch file I created based on Lazarus 4.99 (rev main_4_99-2821-gcab4db5c42) FPC 3.3.1 x86_64-darwin-cocoa.
The Laz hash of the trunk version I'm running should be "cab4db5c42" according to FPCUpDeluxe (had trouble building a more recent Lazarus trunk version).
Also attached a screenshot with and without a title caption in the file dialog.
Please let me know what you guys think 😊