X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/829a2e9521175cd943d671f16535242a467c4f91..d6f2a8911e509fd9e61f881cc881a97f5aa05ae8:/src/cocoa/toplevel.mm?ds=sidebyside diff --git a/src/cocoa/toplevel.mm b/src/cocoa/toplevel.mm index fbcf064b1b..f2e44d4b44 100644 --- a/src/cocoa/toplevel.mm +++ b/src/cocoa/toplevel.mm @@ -36,6 +36,9 @@ #include "wx/cocoa/objc/NSView.h" #include "wx/cocoa/objc/NSWindow.h" #import +#import +#import + // ---------------------------------------------------------------------------- // globals // ---------------------------------------------------------------------------- @@ -139,7 +142,7 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent, else newWindow = [[WXNSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]; // Make sure the default content view is a WXNSView - [newWindow setContentView: [[WXNSView alloc] initWithFrame: [[newWindow contentView] frame]]]; + [newWindow setContentView: [[WX_GET_OBJC_CLASS(WXNSView) alloc] initWithFrame: [[newWindow contentView] frame]]]; // Associate the window and view SetNSWindow(newWindow); @@ -352,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;