X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a24aa4279a8ef9c25b7d0a512a1def0d823ef8f7..5a1e0e91a1ca5ec98b0eeb335cda757d1261ed08:/src/cocoa/toplevel.mm diff --git a/src/cocoa/toplevel.mm b/src/cocoa/toplevel.mm index 83dd00623d..f2e44d4b44 100644 --- a/src/cocoa/toplevel.mm +++ b/src/cocoa/toplevel.mm @@ -36,6 +36,8 @@ #include "wx/cocoa/objc/NSView.h" #include "wx/cocoa/objc/NSWindow.h" #import +#import +#import // ---------------------------------------------------------------------------- // globals @@ -353,6 +355,28 @@ wxString wxTopLevelWindowCocoa::GetTitle() const return wxStringWithNSString([m_cocoaNSWindow title]); } +wxWindow* wxTopLevelWindowCocoa::SetDefaultItem(wxWindow *win) +{ + wxWindow *old = wxTopLevelWindowBase::SetDefaultItem(win); + NSView *newView = win->GetNSView(); + + NSCell *newCell; + // newView does not have to be an NSControl, we only cast to NSControl* + // to silence the warning about cell not being implemented. + if(newView != nil && [newView respondsToSelector:@selector(cell)]) + newCell = [(NSControl*)newView cell]; + else + newCell = nil; + + if(newCell != nil && ![newCell isKindOfClass:[NSButtonCell class]]) + { // It's not an NSButtonCell, set the default to nil. + newCell = nil; + } + + [GetNSWindow() setDefaultButtonCell:(NSButtonCell*)newCell]; + return old; +} + bool wxTopLevelWindowCocoa::ShowFullScreen(bool show, long style) { return false;