X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95fb31530e382c4b355b0c853121441ec97aec24..7e4952db837344e369ff9ccc7ece1f7b8c207cf1:/src/osx/cocoa/window.mm diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 0d5b7b9651..822bf528c7 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -73,6 +73,8 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const - (void)setImage:(NSImage *)image; - (void)setControlSize:(NSControlSize)size; +- (void)setFont:(NSFont *)fontObject; + - (id)contentView; - (void)setTarget:(id)anObject; @@ -801,7 +803,8 @@ bool wxWidgetCocoaImpl::becomeFirstResponder(WXWidget slf, void *_cmd) { wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd]; // get the current focus before running becomeFirstResponder - NSView* otherView = [[NSApp keyWindow] firstResponder]; + NSResponder* currentResponder = [[NSApp keyWindow] firstResponder]; + NSView* otherView = (currentResponder != nil && [currentResponder isKindOfClass:[NSView class]]) ? (NSView*) currentResponder : NULL; wxWidgetImpl* otherWindow = FindFromWXWidget(otherView); BOOL r = superimpl(slf, (SEL)_cmd); if ( r ) @@ -814,7 +817,8 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd) wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd]; BOOL r = superimpl(slf, (SEL)_cmd); // get the current focus after running resignFirstResponder - NSView* otherView = [[NSApp keyWindow] firstResponder]; + NSResponder* currentResponder = [[NSApp keyWindow] firstResponder]; + NSView* otherView = (currentResponder != nil && [currentResponder isKindOfClass:[NSView class]]) ? (NSView*) currentResponder : NULL; wxWidgetImpl* otherWindow = FindFromWXWidget(otherView); if ( r ) DoNotifyFocusEvent( false, otherWindow ); @@ -1076,7 +1080,7 @@ void wxWidgetCocoaImpl::Move(int x, int y, int width, int height) wxWindowMac* parent = GetWXPeer()->GetParent(); // under Cocoa we might have a contentView in the wxParent to which we have to // adjust the coordinates - if (parent) + if (parent && [m_osxView superview] != parent->GetHandle() ) { int cx = 0,cy = 0,cw = 0,ch = 0; if ( parent->GetPeer() ) @@ -1348,11 +1352,7 @@ void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant ) void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&, long, bool) { if ([m_osxView respondsToSelector:@selector(setFont:)]) -#if wxOSX_USE_CORE_TEXT - [m_osxView setFont: (CTFontRef)font.MacGetCTFont()]; -#else - -#endif + [m_osxView setFont: font.GetNSFont()]; } void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )