Search code examples
cocoamacosnsopenpanel

Changing the text of the cancel button of an NSOpenPanel (Cocoa OSX)


I would like to have a customizable chooser where many features may be customized. One thing I cannot figure out how to do is change the text of the cancel button. I found that the method setPrompt will change the text of the okay button but I can find no similar method for the cancel button, is there such a method?


Solution

  • There isn’t a built-in method for it, but you could try iterating through the panel’s content view’s subviews and looking for the button whose action is cancel:, and calling setTitle: on that.

    Update: There's a private _setCancelButtonTitle: method, also.

    (Also, both of these will probably break in a sandboxed app.)