cocoa: Basic support for select directory dialog

git-svn-id: trunk@49586 -
This commit is contained in:
sekelsenmat 2015-08-01 11:32:50 +00:00
parent b7c800ae6d
commit 38e7f694c0
2 changed files with 15 additions and 7 deletions

View File

@ -1943,7 +1943,7 @@ procedure TCocoaContext.ClearClipping;
var
Trans: CGAffineTransform;
begin
if FClipped then
if FClipped then
begin
Trans := CGContextGetCTM(CGContext);
CGContextRestoreGState(CGContext());

View File

@ -173,14 +173,24 @@ begin
//todo: Options
if FileDialog.FCompStyle = csOpenFileDialog then
if (FileDialog.FCompStyle = csOpenFileDialog) or
(FileDialog is TSelectDirectoryDialog) then
begin
openDlg := NSOpenPanel.openPanel;
openDlg.setAllowsMultipleSelection(ofAllowMultiSelect in
TOpenDialog(FileDialog).Options);
openDlg.setCanChooseFiles(True);
if (FileDialog is TSelectDirectoryDialog) then
begin
openDlg.setCanChooseDirectories(True);
openDlg.setCanChooseFiles(False);
end
else
begin
openDlg.setCanChooseFiles(True);
openDlg.setCanChooseDirectories(False);
openDlg.setAllowedFileTypes(nsfilter);
end;
openDlg.setTitle(NSStringUtf8(FileDialog.Title));
openDlg.setAllowedFileTypes(nsfilter);
openDlg.setDirectoryURL(NSURL.fileURLWithPath(NSStringUtf8(FileDialog.InitialDir)));
if openDlg.runModal = NSOKButton then
@ -192,10 +202,8 @@ begin
NSURL(openDlg.URLs.objectAtIndex(i)).path));
FileDialog.UserChoice := mrOk;
end;
end
else
if FileDialog.FCompStyle = csSaveFileDialog then
else if FileDialog.FCompStyle = csSaveFileDialog then
begin
saveDlg := NSSavePanel.savePanel;
saveDlg.setCanCreateDirectories(True);