Procházet zdrojové kódy

dialog: fix default file name on Cocoa

Anon Ymous před 2 měsíci
rodič
revize
b2d152e51f
1 změnil soubory, kde provedl 8 přidání a 1 odebrání
  1. 8 1
      src/dialog/cocoa/SDL_cocoadialog.m

+ 8 - 1
src/dialog/cocoa/SDL_cocoadialog.m

@@ -158,7 +158,14 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
     [dialog setAllowsOtherFileTypes:YES];
 
     if (default_location) {
-        [dialog setDirectoryURL:[NSURL fileURLWithPath:[NSString stringWithUTF8String:default_location]]];
+        char last = default_location[SDL_strlen(default_location) - 1];
+        NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:default_location]];
+        if (last == '/') {
+            [dialog setDirectoryURL:url];
+        } else {
+            [dialog setDirectoryURL:[url URLByDeletingLastPathComponent]];
+            [dialog setNameFieldStringValue:[url lastPathComponent]];
+        }
     }
 
     NSWindow *w = NULL;