Post

Replies

Boosts

Views

Activity

In Save Panel, can’t control the file extension
My Mac app (written in Objective-C) can save a document in two file formats: one with an exported type identifier (extension "gop"), and another with an imported file identifier (extension "sgf"). I want the user to be able to choose in the app’s preferences the default file save format they prefer. My prepareSavePanel: method (see below) reads the user’s preference in this regard, lists the two formats in the correct order — chosen default first. The popup menu in the save panel I get conforms to my expectations (formats in the correct order), BUT the file extension I get in the file name field after the defaultDraftName is always "gop"! Is there any way to get the app to select the extension "sgf" in the save panel popup menu when the user prefers "sgf"? - (BOOL)prepareSavePanel:(NSSavePanel *)savePanel { if (@available(macOS 11.0, *)) { NSArray<UTType *> *UTTypes = nil; UTType * const myTypeGOP = [UTType typeWithFilenameExtension:@"gop"]; UTType * const myTypeSGF = [UTType typeWithFilenameExtension:@"sgf"]; NSInteger const i = [FLPreferenceControler defaultDocumentType]; if (i <= 0) { UTTypes = [NSArray arrayWithObjects:myTypeGOP, myTypeSGF, nil]; } else { /* i > 0. */ UTTypes = [NSArray arrayWithObjects:myTypeSGF, myTypeGOP, nil]; } [savePanel setAllowedContentTypes:aUTTypes]; } else { /* macOS < 11.0. */ NSArray <NSString *> * const UTIs = [self writableTypesForSaveOperation:0]; /* This method does the same as above, but for UTIs instead of UTType’s. */ [savePanel setAllowedFileTypes:UTIs]; } return YES; }
0
0
473
Mar ’23
How to draw in background window
Hello! I’m writing a macOS app. I have a custom view in every document window. Suppose I have two documents open at the same time. Call the two corresponding windows A and B. There are often long background calculations going on in both documents. Suppose A is main. Now, whenever the window behind, B, updates its custom view to reflect the calculations’ progress, B is immediately brought in front of A, but without becoming main! Sometimes both windows will automatically alternate one in front of the other! How can I draw in the custom view of B, the window behind, without bringing it in front of A?
3
0
711
Nov ’20