diff --git a/include/wx/event.h b/include/wx/event.h index 5e1d7b305b..4f6aca1f80 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1496,7 +1496,14 @@ class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent, public wxEventBasicPayloadMixin { public: - wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); + wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) + : wxEvent(winid, commandType) + { + m_clientData = NULL; + m_clientObject = NULL; + + Init(); + } wxCommandEvent(const wxCommandEvent& event) : wxEvent(event), @@ -1508,6 +1515,8 @@ public: // need to copy it explicitly. if ( m_cmdString.empty() ) m_cmdString = event.GetString(); + + Init(); } // Set/Get client data from controls @@ -1539,6 +1548,14 @@ protected: wxClientData* m_clientObject; // Arbitrary client object private: + void Init() + { + m_isCommandEvent = true; + + // the command events are propagated upwards by default + m_propagationLevel = wxEVENT_PROPAGATE_MAX; + } + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent) }; diff --git a/src/common/event.cpp b/src/common/event.cpp index eb5070ad4f..e1457b408e 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -423,17 +423,6 @@ wxEvent& wxEvent::operator=(const wxEvent& src) // wxCommandEvent // ---------------------------------------------------------------------------- -wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId) - : wxEvent(theId, commandType) -{ - m_clientData = NULL; - m_clientObject = NULL; - m_isCommandEvent = true; - - // the command events are propagated upwards by default - m_propagationLevel = wxEVENT_PROPAGATE_MAX; -} - wxString wxCommandEvent::GetString() const { // This is part of the hack retrieving the event string from the control