NSSavePanel: Suppression of "replacement confirmation"? dialogue

In the world of Nav services, you can specify it kNavDontConfirmReplacementas an opportunity to create NavDialogRefone that does not ask the user to confirm the replacement of the file when saving with an existing file name. How to specify equivalent behavior with Cocoa NSSavePanel?

+3
source share
3 answers

Here's how to do it:

  • Add delegate to handle NSSavePanel callbacks
  • Override - (NSString*)panel:(id)sender userEnteredFilename:(NSString*)filename confirmed:(BOOL)okFlagin your deletion
  • In the delegate:
    • If okFlag- false, returnfilename
    • Otherwise, save filenameas NSString*in your deletion
    • ,
  • NSSavePanel , , NSSavePanel ( ).

userEnteredFilename: -, , , . , .

, .

+4

, NSSavePanel. NSSavePanel . , .

0

NSSavePanel, .

, - , NSOpenPanel " "? ( , setAccessoryView API.)

, , NSOpenPanel ; ( ), " " - .

0

Source: https://habr.com/ru/post/1726091/


All Articles