]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/textctrl.mm
fixing class
[wxWidgets.git] / src / osx / cocoa / textctrl.mm
index 0eb4afc84edd3e0a89d77050726df4cc9d3d2e84..b1364c509c5ae9ef478dff011c9788f04c4423c2 100644 (file)
@@ -867,7 +867,12 @@ void wxNSTextFieldControl::WriteText(const wxString& str)
     if ( editor )
     {
         wxMacEditHelper helper(m_textField);
+        BOOL hasUndo = [editor respondsToSelector:@selector(setAllowsUndo:)];
+        if ( hasUndo )
+            [editor setAllowsUndo:NO];
         [editor insertText:wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
+        if ( hasUndo )
+            [editor setAllowsUndo:YES];
     }
     else
     {
@@ -923,6 +928,7 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
         wxNSTextScrollView* v = nil;
         v = [[wxNSTextScrollView alloc] initWithFrame:r];
         c = new wxNSTextViewControl( wxpeer, v );
+        c->SetNeedsFocusRect( true );
     }
     else
     {
@@ -940,25 +946,31 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
         {
             [v setAlignment:NSCenterTextAlignment];
         }
-        
-        if ( style & wxNO_BORDER )
-        {
-            // FIXME: How can we remove the native control's border?
-            // setBordered is separate from the text ctrl's border.
-        }
-        
+                
         NSTextFieldCell* cell = [v cell];
         [cell setScrollable:YES];
         // TODO: Remove if we definitely are sure, it's not needed
         // as setting scrolling to yes, should turn off any wrapping
         // [cell setLineBreakMode:NSLineBreakByClipping]; 
 
-        [v setBezeled:NO];
-        [v setBordered:NO];
-
         c = new wxNSTextFieldControl( wxpeer, wxpeer, v );
+        
+        if ( (style & wxNO_BORDER) || (style & wxSIMPLE_BORDER) )
+        {
+            // under 10.7 the textcontrol can draw its own focus
+            // even if no border is shown, on previous systems
+            // we have to emulate this
+            [v setBezeled:NO];
+            [v setBordered:NO];
+            if ( UMAGetSystemVersion() < 0x1070 )
+                c->SetNeedsFocusRect( true );
+        }
+        else
+        {
+            // use native border
+            c->SetNeedsFrame(false);
+        }
     }
-    c->SetNeedsFocusRect( true );
 
     return c;
 }