ftp.nice.ch/peanuts/GeneralData/Documents/books/AlexNeXTSTEPSource.tar.gz#/NSProgramming/Chapter6_Events/DelegateDemo/WindowDelegate.m

This is WindowDelegate.m in view mode; [Download] [Up]

#import <appkit/appkit.h>
#import "WindowDelegate.h"

#define	SAVE	NX_ALERTDEFAULT
#define	CLOSE	NX_ALERTALTERNATE
#define	CANCEL	NX_ALERTOTHER

@implementation WindowDelegate

- windowWillClose:sender
{
	int result;
	result = NXRunAlertPanel
		([NXApp appName],
		"Unsaved changes. Close Anyway?\n",
		"Save",
		"Close anyway",
		"Cancel");

	switch(result)
		{
		case SAVE:
			printf("Save button selected\n");
			printf("Saving...\n");
			printf("Closing window\n\n");
			break;
		case CLOSE:
			printf("Close button selected\n");
			printf("Closing window\n\n");
			break;
		case CANCEL:
			printf("Cancel button selected\n");
			printf("Window won't close\n\n");
			return nil;
		}
	return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.