]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/textctrl.mm
clang warnings
[wxWidgets.git] / src / osx / cocoa / textctrl.mm
index 32464f3636336cfee51d3fc6e4cc7e9c5b633697..7703e852a6ad5d2d1965f9c8d7bef019c9bf0370 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:))
+            {
+                [textView insertTabIgnoringFieldEditor:self];
+                handled = YES;
+            }
+            else if ( commandSelector == @selector(insertBacktab:))
             {
-                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;
             }
         }
     }
-
-    return NO;
+    
+    return handled;
 }
 
 - (void)controlTextDidEndEditing:(NSNotification *)aNotification
@@ -673,6 +684,13 @@ void wxNSTextFieldControl::controlAction(WXWidget WXUNUSED(slf),
     }
 }
 
+bool wxNSTextFieldControl::SetHint(const wxString& hint)
+{
+    wxCFStringRef hintstring(hint);
+    [[m_textField cell] setPlaceholderString:hintstring.AsNSString()];
+    return true;
+}
+
 //
 //
 //