]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/textctrl.mm
Applied [ 1708971 ] Make a virtual function to enable/disable docking
[wxWidgets.git] / src / cocoa / textctrl.mm
index d755334440dc98d2d1744b34a50c3e8cc6e77e49..cbab8ea2f1850e8a81d6a775864aa53fe401bbba 100644 (file)
@@ -59,6 +59,10 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
     if(m_parent)
         m_parent->CocoaAddChild(this);
     SetInitialFrameRect(pos,size);
+
+    [(NSTextField*)m_cocoaNSView setTarget: sm_cocoaTarget];
+    [(NSTextField*)m_cocoaNSView setAction:@selector(wxNSControlAction:)];
+    
     return true;
 }
 
@@ -71,6 +75,19 @@ void wxTextCtrl::Cocoa_didChangeText(void)
 {
 }
 
+void wxTextCtrl::CocoaTarget_action(void)
+{
+    // NSTextField only sends the action message on enter key press and thus
+    // we send the appropriate event type.
+    wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, GetId());
+
+    // See wxTextCtrlBase::SendTextUpdatedEvent for why we don't set the string.
+    //event.SetString(GetValue());
+
+    event.SetEventObject(this);
+    GetEventHandler()->ProcessEvent(event);
+}
+
 void wxTextCtrl::AppendText(wxString const&)
 {
 }