+@interface wxNSPanel : NSPanel
+{
+}
+
+- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
+- (void)noResponderFor: (SEL) selector;
+- (void)sendEvent:(NSEvent *)event;
+- (BOOL)makeFirstResponder:(NSResponder *)aResponder;
+@end
+
+@implementation wxNSPanel
+
+- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
+{
+ wxNonOwnedWindowCocoaImpl* impl = (wxNonOwnedWindowCocoaImpl*) wxNonOwnedWindowImpl::FindFromWXWindow( self );
+ if (impl && impl->IsFullScreen())
+ return frameRect;
+ else
+ return [super constrainFrameRect:frameRect toScreen:screen];
+}
+
+- (BOOL)canBecomeKeyWindow
+{
+ return YES;
+}
+
+- (void)doCommandBySelector:(SEL)selector
+{
+ if (shouldHandleSelector(selector))
+ [super doCommandBySelector:selector];
+}
+
+// NB: if we don't do this, it seems that all events that end here lead to a NSBeep
+- (void)noResponderFor: (SEL) selector
+{
+ if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
+ {
+ [super noResponderFor:selector];
+ }
+}
+
+- (void)sendEvent:(NSEvent *) event
+{
+ if ( ![self WX_filterSendEvent: event] )
+ {
+ WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
+ WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
+
+ if (wxTheApp)
+ wxTheApp->MacSetCurrentEvent(event, NULL);
+
+ [super sendEvent: event];
+
+ if (wxTheApp)
+ wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
+ }
+}
+
+- (BOOL)makeFirstResponder:(NSResponder *)aResponder
+{
+ s_nextFirstResponder = aResponder;
+ BOOL retval = [super makeFirstResponder:aResponder];
+ s_nextFirstResponder = nil;
+ return retval;
+}