Implement windowShouldClose: in delegate instead of class poser
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23295 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
- (void)windowDidBecomeKey: (NSNotification *)notification;
|
||||
- (void)windowDidResignKey: (NSNotification *)notification;
|
||||
- (BOOL)windowShouldClose: (id)sender;
|
||||
@end //interface wxNSWindowDelegate
|
||||
|
||||
@implementation wxNSWindowDelegate : NSObject
|
||||
@@ -57,6 +58,19 @@
|
||||
win->CocoaNotification_DidResignKey();
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose: (id)sender
|
||||
{
|
||||
wxLogDebug("windowShouldClose");
|
||||
wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(sender);
|
||||
if(tlw && !tlw->Cocoa_windowShouldClose())
|
||||
{
|
||||
wxLogDebug("Window will not be closed");
|
||||
return NO;
|
||||
}
|
||||
wxLogDebug("Window will be closed");
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end //implementation wxNSWindowDelegate
|
||||
|
||||
// ============================================================================
|
||||
@@ -94,8 +108,6 @@ void wxCocoaNSWindow::DisassociateNSWindow(WX_NSWindow cocoaNSWindow)
|
||||
}
|
||||
|
||||
- (void)close;
|
||||
- (BOOL)windowShouldClose: (id)sender;
|
||||
|
||||
@end // wxPoserNSwindow
|
||||
|
||||
WX_IMPLEMENT_POSER(wxPoserNSWindow);
|
||||
@@ -110,17 +122,5 @@ WX_IMPLEMENT_POSER(wxPoserNSWindow);
|
||||
[super close];
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose: (id)sender
|
||||
{
|
||||
wxLogDebug("windowShouldClose");
|
||||
wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(sender);
|
||||
if(tlw && !tlw->Cocoa_windowShouldClose())
|
||||
return NO;
|
||||
wxLogDebug("Window will most likely be CLOSED");
|
||||
if([[wxPoserNSWindow superclass] instancesRespondToSelector:@selector(windowShouldClose:)])
|
||||
return [super windowShouldClose: sender];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end // implementation wxPoserNSWindow
|
||||
|
||||
|
Reference in New Issue
Block a user