]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/spinctrl_osx.cpp
Compilo
[wxWidgets.git] / src / osx / spinctrl_osx.cpp
index 3d2ed855aaa673a713e42490de7487d85c0db8a8..a5849cde3f97a1d4ea8a511554e3ec9a16aeaf93 100644 (file)
@@ -41,8 +41,8 @@ static const wxCoord MARGIN = 3;
 class wxSpinCtrlText : public wxTextCtrl
 {
 public:
-    wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value)
-        : wxTextCtrl(spin , wxID_ANY, value, wxDefaultPosition, wxSize(40, wxDefaultCoord))
+    wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value, int style)
+        : wxTextCtrl(spin , wxID_ANY, value, wxDefaultPosition, wxSize(40, wxDefaultCoord), style )
     {
         m_spin = spin;
 
@@ -60,7 +60,14 @@ public:
     }
 
 protected:
-     void OnKillFocus(wxFocusEvent& WXUNUSED(event))
+     void OnSetFocus(wxFocusEvent& event)
+     {
+         // delegate to parent control
+         event.SetEventObject( GetParent() );
+         GetParent()->HandleWindowEvent(event);
+     }
+     
+     void OnKillFocus(wxFocusEvent& event)
      {
          long l;
          if ( !GetValue().ToLong(&l) )
@@ -88,13 +95,17 @@ protected:
              m_spin->m_btn->SetValue( l );
 
              // if not
-             wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, m_spin->GetId());
-             event.SetEventObject(m_spin);
-             event.SetInt(l);
-             m_spin->HandleWindowEvent(event);
+             wxCommandEvent cevent(wxEVT_COMMAND_SPINCTRL_UPDATED, m_spin->GetId());
+             cevent.SetEventObject(m_spin);
+             cevent.SetInt(l);
+             m_spin->HandleWindowEvent(cevent);
 
              m_spin->m_oldValue = l;
          }
+         
+         // delegate to parent control
+         event.SetEventObject( GetParent() );
+         GetParent()->HandleWindowEvent(event);
     }
 
     void OnTextChange(wxCommandEvent& event)
@@ -133,7 +144,8 @@ private:
 
 BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl)
     EVT_TEXT(wxID_ANY, wxSpinCtrlText::OnTextChange)
-    EVT_KILL_FOCUS( wxSpinCtrlText::OnKillFocus)
+    EVT_SET_FOCUS(wxSpinCtrlText::OnSetFocus)
+    EVT_KILL_FOCUS(wxSpinCtrlText::OnKillFocus)
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
@@ -238,7 +250,7 @@ bool wxSpinCtrl::Create(wxWindow *parent,
     }
 
     wxSize csize = size ;
-    m_text = new wxSpinCtrlText(this, value);
+    m_text = new wxSpinCtrlText(this, value, style & wxTE_PROCESS_ENTER ? wxTE_PROCESS_ENTER : 0 );
     m_btn = new wxSpinCtrlButton(this, style);
 
     m_btn->SetRange(min, max);