X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce7fe42e848cc0c9058dae906c3a7bded50681e6..7c60222510bc5e197b12f153c4bf05db66cb0f4a:/src/osx/cocoa/textctrl.mm diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 6c4b6c1a88..14f3a176e1 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -111,6 +111,7 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; @interface wxMaximumLengthFormatter : NSFormatter { int maxLength; + wxTextEntry* field; } @end @@ -148,12 +149,17 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; int len = [*partialStringPtr length]; if ( maxLength > 0 && len > maxLength ) { - // TODO wxEVT_TEXT_MAXLEN + field->SendMaxLenEvent(); return NO; } return YES; } +- (void) setTextEntry:(wxTextEntry*) tf +{ + field = tf; +} + @end @implementation wxNSSecureTextField @@ -182,7 +188,11 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); if ( impl ) { - impl->DoNotifyFocusEvent( false, NULL ); + NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder(); + NSView* otherView = wxOSXGetViewFromResponder(responder); + + wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView); + impl->DoNotifyFocusEvent( false, otherWindow ); } } @@ -336,7 +346,11 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); if ( impl ) { - impl->DoNotifyFocusEvent( false, NULL ); + NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder(); + NSView* otherView = wxOSXGetViewFromResponder(responder); + + wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView); + impl->DoNotifyFocusEvent( false, otherWindow ); } } @@ -506,7 +520,11 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; timpl->SetInternalSelection(range.location, range.location + range.length); } - impl->DoNotifyFocusEvent( false, NULL ); + NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder(); + NSView* otherView = wxOSXGetViewFromResponder(responder); + + wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView); + impl->DoNotifyFocusEvent( false, otherWindow ); } } @end @@ -793,6 +811,7 @@ void wxNSTextFieldControl::SetMaxLength(unsigned long len) { wxMaximumLengthFormatter* formatter = [[[wxMaximumLengthFormatter alloc] init] autorelease]; [formatter setMaxLength:len]; + [formatter setTextEntry:GetTextEntry()]; [m_textField setFormatter:formatter]; }