From 77b763f8badc7c8fdae0cd962e29c0b574f43edb Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 5 Dec 2022 15:34:20 -0800 Subject: [PATCH] Change binding with units --- common/widgets/unit_binder.cpp | 25 +++++++++++++++++++++++++ include/widgets/unit_binder.h | 3 +-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 5b36288ef6..708281600f 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -619,3 +619,28 @@ PROPERTY_EDITOR_UNIT_BINDER::PROPERTY_EDITOR_UNIT_BINDER( EDA_DRAW_FRAME* aParen PROPERTY_EDITOR_UNIT_BINDER::~PROPERTY_EDITOR_UNIT_BINDER() { } + +void PROPERTY_EDITOR_UNIT_BINDER::SetControl( wxWindow* aControl ) +{ + if( m_valueCtrl ) + { + m_valueCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onSetFocus ), + nullptr, this ); + m_valueCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onKillFocus ), + nullptr, this ); + m_valueCtrl->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onClick ), + nullptr, this ); + } + + m_valueCtrl = aControl; + + if( m_valueCtrl ) + { + m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onSetFocus ), + nullptr, this ); + m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onKillFocus ), + nullptr, this ); + m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onClick ), + nullptr, this ); + } +} diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index e78d10dd11..6f8fcc214b 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -37,7 +37,6 @@ class wxTextEntry; class wxSpinButton; class wxStaticText; - class UNIT_BINDER : public wxEvtHandler { public: @@ -266,7 +265,7 @@ public: virtual ~PROPERTY_EDITOR_UNIT_BINDER(); - void SetControl( wxWindow* aControl ) { m_valueCtrl = aControl; } + void SetControl( wxWindow* aControl ); }; #endif /* __UNIT_BINDER_H_ */