]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/textctrl.mm
Add wxTimer::StartOnce().
[wxWidgets.git] / src / osx / cocoa / textctrl.mm
index 6c4b6c1a88460e7a83b516b36ab85933c01d0472..14f3a176e148796ef03b920d8f18cbe35c5c41e6 100644 (file)
@@ -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];
 }