Reconnect wxPropertyGridManager event handlers when wxPG id is changing.

Because some event handlers are bound to the particular id's they need to be reconnected when wxPG id is the subject of change.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78259 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2014-12-09 17:07:59 +00:00
parent 2fe72022e3
commit de2f5898c4
2 changed files with 26 additions and 8 deletions

View File

@@ -750,6 +750,8 @@ protected:
virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) wxOVERRIDE;
virtual wxVariant GetEditableStateItem( const wxString& name ) const wxOVERRIDE;
// Reconnect propgrid event handlers.
void ReconnectEventHandlers(wxWindowID oldId, wxWindowID newId);
private:
DECLARE_EVENT_TABLE()
};

View File

@@ -584,13 +584,7 @@ void wxPropertyGridManager::Init2( int style )
// Connect to property grid onselect event.
// NB: Even if wxID_ANY is used, this doesn't connect properly in wxPython
// (see wxPropertyGridManager::ProcessEvent).
Connect(m_pPropGrid->GetId(),
wxEVT_PG_SELECTED,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect));
Connect(m_pPropGrid->GetId(),
wxEVT_PG_COL_DRAGGING,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag));
ReconnectEventHandlers(wxID_NONE, m_pPropGrid->GetId());
// Optional initial controls.
m_width = -12345;
@@ -630,7 +624,8 @@ void wxPropertyGridManager::SetId( wxWindowID winid )
{
wxWindow::SetId(winid);
// TODO: Reconnect propgrid event handler(s).
// Reconnect propgrid event handlers.
ReconnectEventHandlers(m_pPropGrid->GetId(), winid);
m_pPropGrid->SetId(winid);
}
@@ -1906,6 +1901,27 @@ void wxPropertyGridManager::SetPageSplitterLeft(int page, bool subProps)
}
}
void wxPropertyGridManager::ReconnectEventHandlers(wxWindowID oldId, wxWindowID newId)
{
wxASSERT( oldId != newId );
if (oldId != wxID_NONE)
{
Disconnect(oldId, wxEVT_PG_SELECTED,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect));
Disconnect(oldId, wxEVT_PG_COL_DRAGGING,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag));
}
if (newId != wxID_NONE)
{
Connect(newId, wxEVT_PG_SELECTED,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect));
Connect(newId, wxEVT_PG_COL_DRAGGING,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag));
}
}
// -----------------------------------------------------------------------
void wxPropertyGridManager::OnPropertyGridSelect( wxPropertyGridEvent& event )