in order to get all focus set events, store field in editor and catch becomeFirstResponder there, see #14269

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76578 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2014-05-18 16:33:57 +00:00
parent 3ba1c7e166
commit cea11b591e
3 changed files with 27 additions and 0 deletions

View File

@ -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(<NSTextFieldDelegate>)

View File

@ -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];
}

View File

@ -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