]> git.saurik.com Git - wxWidgets.git/commitdiff
Handle the remaining selectors which otherwise lead to beeping on key press.
authorKevin Ollivier <kevino@theolliviers.com>
Tue, 17 Mar 2009 21:04:15 +0000 (21:04 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Tue, 17 Mar 2009 21:04:15 +0000 (21:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59588 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/nonownedwnd.mm

index 48abcb3a90a347e52596e3d7b443daa16e0b3928..2328590c819a718a52c8d1cace14b783fc99c6a8 100644 (file)
@@ -57,6 +57,26 @@ wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p )
     return wxPoint( x, y);
 }
 
+bool shouldHandleSelector(SEL selector)
+{
+    if (selector == @selector(noop:) 
+            || selector == @selector(complete:)
+            || selector == @selector(deleteBackward:)
+            || selector == @selector(deleteForward:)
+            || selector == @selector(insertNewline:)
+            || selector == @selector(insertTab:)
+            || selector == @selector(keyDown:)
+            || selector == @selector(keyUp:)
+            || selector == @selector(scrollPageUp:)
+            || selector == @selector(scrollPageDown:)
+            || selector == @selector(scrollToBeginningOfDocument:)
+            || selector == @selector(scrollToEndOfDocument:))
+        return false;
+        
+    return true;
+
+}
+
 //
 // wx native implementation classes
 //
@@ -64,7 +84,6 @@ wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p )
 typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector);
 
 @interface wxNSWindow : NSWindow
-
 {
     wxNonOwnedWindowCocoaImpl* impl;
 }
@@ -86,10 +105,18 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
     return impl;
 }
 
+- (void)doCommandBySelector:(SEL)selector
+{
+    if (shouldHandleSelector(selector) && 
+        !(selector == @selector(cancel:) || selector == @selector(cancelOperation:)) )
+        [super doCommandBySelector:selector];
+}
+
+
 // NB: if we don't do this, all key downs that get handled lead to a NSBeep
 - (void)noResponderFor: (SEL) selector
 {
-    if (selector != @selector(keyDown:))
+    if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
     {
         wxOSX_NoResponderHandlerPtr superimpl = (wxOSX_NoResponderHandlerPtr) [[self superclass] instanceMethodForSelector:@selector(noResponderFor:)];
         superimpl(self, @selector(noResponderFor:), selector);
@@ -126,10 +153,16 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
     return impl;
 }
 
-// NB: if we don't do this, all key downs that get handled lead to a NSBeep
+- (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:))
+    if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
     {
         wxOSX_NoResponderHandlerPtr superimpl = (wxOSX_NoResponderHandlerPtr) [[self superclass] instanceMethodForSelector:@selector(noResponderFor:)];
         superimpl(self, @selector(noResponderFor:), selector);