From ea6cbf486a3be57fd10283b3cd65a34e193d3d6c Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 24 May 2008 20:24:58 +0000 Subject: [PATCH] Dont send spin text update event from SetValue() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/spinctrl.h | 3 +++ src/msw/spinctrl.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/spinctrl.h b/include/wx/msw/spinctrl.h index e137d50d6e..d1707c703f 100644 --- a/include/wx/msw/spinctrl.h +++ b/include/wx/msw/spinctrl.h @@ -122,6 +122,9 @@ protected: WXHWND m_hwndBuddy; WXFARPROC m_wndProcBuddy; + // Block text update event after SetValue() + bool m_blockEvent; + // all existing wxSpinCtrls - this allows to find the one corresponding to // the given buddy window in GetSpinForTextCtrl() static wxArraySpins ms_allSpins; diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index a2a38c0437..73fb437fc0 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -205,7 +205,7 @@ wxSpinCtrl *wxSpinCtrl::GetSpinForTextCtrl(WXHWND hwndBuddy) // process a WM_COMMAND generated by the buddy text control bool wxSpinCtrl::ProcessTextCommand(WXWORD cmd, WXWORD WXUNUSED(id)) { - if ( cmd == EN_CHANGE ) + if ( (cmd == EN_CHANGE) && (!m_blockEvent )) { wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId()); event.SetEventObject(this); @@ -301,6 +301,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, int min, int max, int initial, const wxString& name) { + m_blockEvent = false; + // this should be in ctor/init function but I don't want to add one to 2.8 // to avoid problems with default ctor which can be inlined in the user // code and so might not get this fix without recompilation @@ -462,6 +464,8 @@ void wxSpinCtrl::SetValue(const wxString& text) void wxSpinCtrl::SetValue(int val) { + m_blockEvent = true; + wxSpinButton::SetValue(val); // normally setting the value of the spin button is enough as it updates @@ -477,6 +481,8 @@ void wxSpinCtrl::SetValue(int val) } m_oldValue = GetValue(); + + m_blockEvent = false; } int wxSpinCtrl::GetValue() const -- 2.49.0