]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/textctrl.mm
Fail in CloneGDIRefData() instead of implementing it incorrectly in wxOSX.
[wxWidgets.git] / src / osx / cocoa / textctrl.mm
index 77416d23623afa9e218f8e3bce7f133d9e0bef45..6106bedc702ff6c885de5bf3b81ed5278c548fbd 100644 (file)
@@ -253,29 +253,40 @@ protected :
         impl->controlTextDidChange();
 }
 
-typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl *control, NSTextView* textView, SEL commandSelector);
-
 - (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector
 {
     wxUnusedVar(textView);
     wxUnusedVar(control);
-    if (commandSelector == @selector(insertNewline:))
+    
+    BOOL handled = NO;
+
+    // send back key events wx' common code knows how to handle
+    
+    wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+    if ( impl  )
     {
-        wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
-        if ( impl  )
+        wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+        if ( wxpeer )
         {
-            wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
-            if ( wxpeer && wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER )
+            if (commandSelector == @selector(insertNewline:))
+            {
+                [textView insertNewlineIgnoringFieldEditor:self];
+                handled = YES;
+            }
+            else if ( commandSelector == @selector(insertTab:))
             {
-                wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
-                event.SetEventObject( wxpeer );
-                event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
-                wxpeer->HandleWindowEvent( event );
+                [textView insertTabIgnoringFieldEditor:self];
+                handled = YES;
+            }
+            else if ( commandSelector == @selector(insertBacktab:))
+            {
+                [textView insertTabIgnoringFieldEditor:self];
+                handled = YES;
             }
         }
     }
-
-    return NO;
+    
+    return handled;
 }
 
 - (void)controlTextDidEndEditing:(NSNotification *)aNotification
@@ -517,6 +528,7 @@ wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *text, WXWidget w )
     : wxWidgetCocoaImpl(text, w),
       wxTextWidgetImpl(text)
 {
+    Init(w);
 }
 
 wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer,
@@ -525,6 +537,7 @@ wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer,
     : wxWidgetCocoaImpl(wxPeer, w),
       wxTextWidgetImpl(entry)
 {
+    Init(w);
 }
 
 void wxNSTextFieldControl::Init(WXWidget w)
@@ -706,6 +719,12 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
             // 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];