mirror of
https://github.com/darlinghq/darling-metal.git
synced 2024-11-26 22:20:22 +00:00
[examples] Terminate app when closing window
This commit is contained in:
parent
ea1653793a
commit
f61e92d1cc
@ -8,11 +8,28 @@
|
||||
|
||||
#import "Renderer/AAPLRenderer.h"
|
||||
|
||||
@interface WindowDelegate : NSObject<NSWindowDelegate>
|
||||
|
||||
- (void)windowWillClose: (NSNotification*)note;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WindowDelegate
|
||||
|
||||
- (void)windowWillClose: (NSNotification*)note
|
||||
{
|
||||
[[NSApplication sharedApplication] terminate: self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
[NSAutoreleasePool new];
|
||||
[NSApplication sharedApplication];
|
||||
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
|
||||
|
||||
WindowDelegate* winDelegate = [WindowDelegate new];
|
||||
|
||||
NSMenu* menubar = [[NSMenu new] autorelease];
|
||||
NSMenuItem* appMenuItem = [[NSMenuItem new] autorelease];
|
||||
|
||||
@ -52,6 +69,7 @@ int main(int argc, char** argv) {
|
||||
view.delegate = renderer;
|
||||
|
||||
window.contentView = view;
|
||||
window.delegate = winDelegate;
|
||||
|
||||
[NSApp run];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user