Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
I thought this was the way to simulate a click on the red close button at the top left corner of a window:

[NSApp sendAction:mad:selector(performClose:) to:nil from:self];

Oddly, this does not close the window when there is an open unsaved document. (A save dialog appears, and after it is dismissed the window is still open.) Clicking the window's close button does close the window, however.

EDIT: Calling the window's -close method does the trick. Sorry to waste anyone's time.
 

Sijmen

macrumors 6502a
Sep 7, 2005
709
1
First off, you're sending a message to nil - that won't do anything.

Secondly, as you said, -[NSWindow close] will close the window. If you want to really simulate clicking the close button (ie, with the highlight of the red button etc), use -[NSWindow performClose].
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.