]> git.saurik.com Git - wxWidgets.git/commitdiff
applying editor part of patch, see #15003
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 10 May 2013 18:31:51 +0000 (18:31 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 10 May 2013 18:31:51 +0000 (18:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/cocoa/private.h
src/osx/cocoa/combobox.mm
src/osx/cocoa/nonownedwnd.mm

index 949558c335633ff6c1faa45dadbc13f34bd452fd..aae59396078ce8836bce59816a8fa425fb86caf4 100644 (file)
@@ -341,6 +341,18 @@ public:
 
     @end
 
+    @interface wxNSComboBox : NSComboBox
+    {
+        wxNSTextFieldEditor* fieldEditor;
+    }
+
+    - (wxNSTextFieldEditor*) fieldEditor;
+    - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
+
+    @end
+
+
+
     @interface wxNSMenu : NSMenu
     {
        wxMenuImpl* impl;
index f001957006cd1d9bd4bd6723571823cb3de83dd4..c410bd23c4653583e6495052cad36e6b99541e14 100644 (file)
 @end
 
 
-@interface wxNSComboBox : NSComboBox
-{
-}
-
-@end
-
 @implementation wxNSComboBox
 
 + (void)initialize
     }
 }
 
+- (void) dealloc
+{
+    [fieldEditor release];
+    [super dealloc];
+}
+
+// Over-riding NSComboBox onKeyDown method doesn't work for key events.
+// Ensure that we can use our own wxNSTextFieldEditor to catch key events.
+// See windowWillReturnFieldEditor in nonownedwnd.mm.
+// Key events will be caught and handled via wxNSTextFieldEditor onkey...
+// methods in textctrl.mm.
+
+- (void) setFieldEditor:(wxNSTextFieldEditor*) editor
+{
+    if ( editor != fieldEditor )
+    {
+        [editor retain];
+        [fieldEditor release];
+        fieldEditor = editor;
+    }
+}
+
+- (wxNSTextFieldEditor*) fieldEditor
+{
+    return fieldEditor;
+}
+
 - (void)controlTextDidChange:(NSNotification *)aNotification
 {
     wxUnusedVar(aNotification);
index 751dc10f73be3bd4cef7b3137722f3462627a8f8..bbba049d28bba4b0e076600fe0fc9fde7256cdc3 100644 (file)
@@ -484,6 +484,19 @@ extern int wxOSXGetIdFromSelector(SEL action );
         }
         return editor;
     } 
+    else if ([anObject isKindOfClass:[wxNSComboBox class]])
+    {
+        wxNSComboBox * cb = (wxNSComboBox*) anObject;
+        wxNSTextFieldEditor* editor = [cb fieldEditor];
+        if ( editor == nil )
+        {
+            editor = [[wxNSTextFieldEditor alloc] init];
+            [editor setFieldEditor:YES];
+            [cb setFieldEditor:editor];
+            [editor release];
+        }
+        return editor;
+    }    
  
     return nil;
 }