X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d6f93922574f0733fde4817445c3575398e2bf7a..ab52bac815bed0189bb0ba3b52a15e093c354533:/src/osx/spinctrl_osx.cpp diff --git a/src/osx/spinctrl_osx.cpp b/src/osx/spinctrl_osx.cpp index 3d2ed855aa..1e56099b01 100644 --- a/src/osx/spinctrl_osx.cpp +++ b/src/osx/spinctrl_osx.cpp @@ -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 | wxALIGN_MASK ) ); m_btn = new wxSpinCtrlButton(this, style); m_btn->SetRange(min, max); @@ -376,9 +388,9 @@ int wxSpinCtrl::GetMax() const void wxSpinCtrl::SetTextValue(int val) { - wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetTextValue") ); + wxCHECK_RET( m_text, wxT("invalid call to wxSpinCtrl::SetTextValue") ); - m_text->SetValue(wxString::Format(_T("%d"), val)); + m_text->SetValue(wxString::Format(wxT("%d"), val)); // select all text m_text->SetSelection(0, -1); @@ -389,7 +401,7 @@ void wxSpinCtrl::SetTextValue(int val) void wxSpinCtrl::SetValue(int val) { - wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetValue") ); + wxCHECK_RET( m_btn, wxT("invalid call to wxSpinCtrl::SetValue") ); SetTextValue(val); @@ -399,7 +411,7 @@ void wxSpinCtrl::SetValue(int val) void wxSpinCtrl::SetValue(const wxString& text) { - wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetValue") ); + wxCHECK_RET( m_text, wxT("invalid call to wxSpinCtrl::SetValue") ); long val; if ( text.ToLong(&val) && ((val > INT_MIN) && (val < INT_MAX)) ) @@ -415,7 +427,7 @@ void wxSpinCtrl::SetValue(const wxString& text) void wxSpinCtrl::SetRange(int min, int max) { - wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetRange") ); + wxCHECK_RET( m_btn, wxT("invalid call to wxSpinCtrl::SetRange") ); m_btn->SetRange(min, max); }