diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 865a4c6395..3b99f4e24e 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -328,8 +328,10 @@ public: @interface wxNSTextFieldEditor : NSTextView { NSEvent* lastKeyDownEvent; + NSTextField* textField; } + - (void) setTextField:(NSTextField*) field; @end @interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER() diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index f0679dc8aa..53c9c0e113 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -520,6 +520,7 @@ extern int wxOSXGetIdFromSelector(SEL action ); { editor = [[wxNSTextFieldEditor alloc] init]; [editor setFieldEditor:YES]; + [editor setTextField:tf]; [tf setFieldEditor:editor]; [editor release]; } @@ -533,6 +534,7 @@ extern int wxOSXGetIdFromSelector(SEL action ); { editor = [[wxNSTextFieldEditor alloc] init]; [editor setFieldEditor:YES]; + [editor setTextField:cb]; [cb setFieldEditor:editor]; [editor release]; } diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index bef1430929..f50b76a738 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -298,6 +298,29 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; [super insertText:str]; } +- (BOOL) resignFirstResponder +{ + return [super resignFirstResponder]; +} + +- (BOOL) becomeFirstResponder +{ + // we need the stored text field, as at this point the delegate is not yet set + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) textField ); + + BOOL r = [super becomeFirstResponder]; + if ( impl != NULL && r ) + impl->DoNotifyFocusSet(); + + return r; +} + +- (void) setTextField:(NSTextField*) field +{ + textField = field; +} + + @end @implementation wxNSTextView