NSOpenPanel - default OK button

Hi there...


I have a NSOpenPanel that I use in my Mac Application to confirm the directory that files will be saved in.

I've used the setPrompt to change the OK text. Now I'd like to be able to have that button be the default - i.e. set a key equivalent.

[panel.okButton setKeyEquivalent:@"\r"];


- David

Replies

Doesn't it already work if you press Enter? No customization should be necessary.

You are right. It does work if you press return. I just tested it.


This may be a bug?


On the NSOpenPanel the OK button is not highlighted as the default button - although it is the default button.

On the NSSavePanel the OK (or Save) button is highlighted as the default button.


Thank you. I appreciate the informative reply.


- David

OK. I see what you're talking about, and it's not a bug. Take a very close look at the buttons in the Open panel; you'll see that there's a bit of subtle shading in them. Those buttons are in the Textured Rounded style, which is designed to be placed over a shaded window toolbar. Textured rounded buttons do not display the blue highlight because it would look funny in a toolbar. If you look at the Save panel buttons, there is no shading there; the ones in the Save panel are just the regular Push style, which does have the highlight.

The reason why the Open panel uses the textured buttons but the Save panel does not is that nowadays the Open panel appears more often with the shaded bottom bar (you know, the new style) than without. The Save panel, on the other hand, has no such style.