diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 5dd94dbeeb..b0d9f2f4c2 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -449,6 +449,17 @@ public: @end + @interface wxNSSearchField : NSSearchField + { + wxNSTextFieldEditor* fieldEditor; + BOOL m_withinTextDidChange; + } + + - (wxNSTextFieldEditor*) fieldEditor; + - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor; + + @end + @interface wxNSComboBox : NSComboBox { wxNSTextFieldEditor* fieldEditor; diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index fecfcdd40a..e6386bdcb5 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -597,6 +597,20 @@ extern int wxOSXGetIdFromSelector(SEL action ); } return editor; } + else if ([anObject isKindOfClass:[wxNSSearchField class]]) + { + wxNSSearchField* sf = (wxNSSearchField*) anObject; + wxNSTextFieldEditor* editor = [sf fieldEditor]; + if ( editor == nil ) + { + editor = [[wxNSTextFieldEditor alloc] init]; + [editor setFieldEditor:YES]; + [editor setTextField:sf]; + [sf setFieldEditor:editor]; + [editor release]; + } + return editor; + } else if ([anObject isKindOfClass:[wxNSComboBox class]]) { wxNSComboBox * cb = (wxNSComboBox*) anObject; diff --git a/src/osx/cocoa/srchctrl.mm b/src/osx/cocoa/srchctrl.mm index d00c43a6a0..b5efe28734 100644 --- a/src/osx/cocoa/srchctrl.mm +++ b/src/osx/cocoa/srchctrl.mm @@ -24,14 +24,6 @@ #include "wx/osx/private.h" #include "wx/osx/cocoa/private/textimpl.h" - -@interface wxNSSearchField : NSSearchField -{ - BOOL m_withinTextDidChange; -} - -@end - @implementation wxNSSearchField + (void)initialize @@ -44,6 +36,21 @@ } } +- (void) setFieldEditor:(wxNSTextFieldEditor*) editor +{ + if ( editor != fieldEditor ) + { + [editor retain]; + [fieldEditor release]; + fieldEditor = editor; + } +} + +- (wxNSTextFieldEditor*) fieldEditor +{ + return fieldEditor; +} + - (id)initWithFrame:(NSRect)frame { if ( self = [super initWithFrame:frame] )