@interface WindowDelegate: NSObject <NSWindowDelegate>
-- (void)windowWillClose:(NSNotification *)notification;
+- (BOOL)windowShouldClose:(id)sender;
@end
{
CocoaDisplay *display;
__strong NSWindow *window;
+ __strong WindowDelegate *delegate;
NSUInteger style;
};
wrapper->window = window;
wrapper->style = style;
- [window setDelegate:[[WindowDelegate alloc] init]];
+ wrapper->delegate = [[WindowDelegate alloc] init];
+ [window setDelegate:wrapper->delegate];
if(!windows)
windows = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
}
[window->window release];
+ [window->delegate release];
free(window);
}
@implementation WindowDelegate
-- (void)windowWillClose:(NSNotification *)notification
+- (BOOL)windowShouldClose:(id)sender
{
- CocoaWindow *window = lookup_window((NSWindow *)[notification object]);
+ CocoaWindow *window = lookup_window((NSWindow *)sender);
if(window)
{
CocoaEvent event;
event.any.type = WINDOW_CLOSED;
event.any.window = window;
queue_event(window->display, &event);
+ return NO;
}
+ return YES;
}
@end