diff --git a/pcbnew/dialogs/panel_setup_netclasses.cpp b/pcbnew/dialogs/panel_setup_netclasses.cpp index ecb8a55f7d..2c3dda32bc 100644 --- a/pcbnew/dialogs/panel_setup_netclasses.cpp +++ b/pcbnew/dialogs/panel_setup_netclasses.cpp @@ -297,7 +297,7 @@ bool PANEL_SETUP_NETCLASSES::validateNetclassName( int aRow, wxString aName, boo for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ ) { - if( ii != aRow && m_netclassGrid->GetRowLabelValue( ii ).CmpNoCase( aName ) == 0 ) + if( ii != aRow && m_netclassGrid->GetCellValue( ii, GRID_NAME ).CmpNoCase( aName ) == 0 ) { wxString msg = _( "Netclass name already in use." ); m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME ); @@ -314,7 +314,18 @@ void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging( wxGridEvent& event ) if( event.GetCol() == GRID_NAME ) { if( validateNetclassName( event.GetRow(), event.GetString() ) ) + { + wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME ); + wxString newName = event.GetString(); + + for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row ) + { + if( m_membershipGrid->GetCellValue( row, 1 ) == oldName ) + m_membershipGrid->SetCellValue( row, 1, newName ); + } + m_netclassesDirty = true; + } else event.Veto(); } @@ -399,6 +410,12 @@ void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid( wxSizeEvent& event ) } +void PANEL_SETUP_NETCLASSES::OnMembershipKillFocus( wxFocusEvent& event ) +{ + m_membershipGrid->CommitPendingChanges(); +} + + void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns( int aWidth ) { // Account for scroll bars diff --git a/pcbnew/dialogs/panel_setup_netclasses.h b/pcbnew/dialogs/panel_setup_netclasses.h index e4c197c0e3..30d6d99811 100644 --- a/pcbnew/dialogs/panel_setup_netclasses.h +++ b/pcbnew/dialogs/panel_setup_netclasses.h @@ -60,6 +60,7 @@ private: void OnSizeMembershipGrid( wxSizeEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent &event ) override; void OnNetclassGridCellChanging( wxGridEvent& event ); + void OnMembershipKillFocus( wxFocusEvent& event ) override; void OnShowAll( wxCommandEvent& event ) override { doApplyFilters( true ); } void OnApplyFilters( wxCommandEvent& event ) override { doApplyFilters( false ); } void OnAssignAll( wxCommandEvent& event ) override { doAssignments( true ); } diff --git a/pcbnew/dialogs/panel_setup_netclasses_base.cpp b/pcbnew/dialogs/panel_setup_netclasses_base.cpp index 6c86a4b23b..7505ae834c 100644 --- a/pcbnew/dialogs/panel_setup_netclasses_base.cpp +++ b/pcbnew/dialogs/panel_setup_netclasses_base.cpp @@ -256,6 +256,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi m_filterNetsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this ); m_assignAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this ); m_assignSelectedButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignSelected ), NULL, this ); + m_membershipGrid->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnMembershipKillFocus ), NULL, this ); m_membershipGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeMembershipGrid ), NULL, this ); } @@ -270,6 +271,7 @@ PANEL_SETUP_NETCLASSES_BASE::~PANEL_SETUP_NETCLASSES_BASE() m_filterNetsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this ); m_assignAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this ); m_assignSelectedButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignSelected ), NULL, this ); + m_membershipGrid->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnMembershipKillFocus ), NULL, this ); m_membershipGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeMembershipGrid ), NULL, this ); } diff --git a/pcbnew/dialogs/panel_setup_netclasses_base.fbp b/pcbnew/dialogs/panel_setup_netclasses_base.fbp index 97a52113e4..5a6944be5b 100644 --- a/pcbnew/dialogs/panel_setup_netclasses_base.fbp +++ b/pcbnew/dialogs/panel_setup_netclasses_base.fbp @@ -1327,6 +1327,7 @@ wxBORDER_DEFAULT + OnMembershipKillFocus OnSizeMembershipGrid diff --git a/pcbnew/dialogs/panel_setup_netclasses_base.h b/pcbnew/dialogs/panel_setup_netclasses_base.h index c9e0504ccc..d771b19fed 100644 --- a/pcbnew/dialogs/panel_setup_netclasses_base.h +++ b/pcbnew/dialogs/panel_setup_netclasses_base.h @@ -66,6 +66,7 @@ class PANEL_SETUP_NETCLASSES_BASE : public wxPanel virtual void OnApplyFilters( wxCommandEvent& event ) { event.Skip(); } virtual void OnAssignAll( wxCommandEvent& event ) { event.Skip(); } virtual void OnAssignSelected( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMembershipKillFocus( wxFocusEvent& event ) { event.Skip(); } virtual void OnSizeMembershipGrid( wxSizeEvent& event ) { event.Skip(); }