From aad2b347a63ceba06dbd0ef02076fd8baa8b3138 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 8 Feb 2016 14:57:46 +0100 Subject: [PATCH] Cross update of composed and decomposed text controls fixed --- ZRCola/zrcolacomppnl.cpp | 32 +++++++++++++++++++++++--------- ZRCola/zrcolacomppnl.h | 3 +++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index 24ebb92..f91c15d 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -24,7 +24,9 @@ // wxZRColaComposerPanel ////////////////////////////////////////////////////////////////////////// -wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : wxZRColaComposerPanelBase(parent) +wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : + m_progress(false), + wxZRColaComposerPanelBase(parent) { } @@ -36,17 +38,29 @@ wxZRColaComposerPanel::~wxZRColaComposerPanel() void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event) { - // TODO: Do the real ZRCola composition here. - m_composed->SetValue(m_decomposed->GetValue()); - - event.Skip(); + if (m_progress) { + // We are being updated by wxZRColaComposerPanel::OnComposedText() + event.Skip(); + } else { + // TODO: Do the real ZRCola composition here. + m_progress = true; + m_composed->SetValue(m_decomposed->GetValue()); + event.Skip(); + m_progress = false; + } } void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event) { - // TODO: Do the real ZRCola decomposition here. - m_decomposed->SetValue(m_composed->GetValue()); - - event.Skip(); + if (m_progress) { + // We are being updated by wxZRColaComposerPanel::OnDecomposedText() + event.Skip(); + } else { + // TODO: Do the real ZRCola decomposition here. + m_progress = true; + m_decomposed->SetValue(m_composed->GetValue()); + event.Skip(); + m_progress = false; + } } diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h index 31dc631..1873869 100644 --- a/ZRCola/zrcolacomppnl.h +++ b/ZRCola/zrcolacomppnl.h @@ -43,4 +43,7 @@ public: protected: virtual void OnDecomposedText(wxCommandEvent& event); virtual void OnComposedText(wxCommandEvent& event); + +protected: + bool m_progress; ///< A boolean flag to avoid recursive updates of composed and decomposed text controls };