diff --git a/eeschema/dialogs/dialog_symbol_fields_table.cpp b/eeschema/dialogs/dialog_symbol_fields_table.cpp index c6933aa0a7..b04923ac66 100644 --- a/eeschema/dialogs/dialog_symbol_fields_table.cpp +++ b/eeschema/dialogs/dialog_symbol_fields_table.cpp @@ -457,6 +457,8 @@ bool DIALOG_SYMBOL_FIELDS_TABLE::TransferDataToWindow() EE_SELECTION& selection = selectionTool->GetSelection(); SCH_SYMBOL* symbol = nullptr; + UpdateScope(); + if( selection.GetSize() == 1 ) { EDA_ITEM* item = selection.Front(); @@ -485,14 +487,33 @@ bool DIALOG_SYMBOL_FIELDS_TABLE::TransferDataToWindow() if( found ) { - m_grid->GoToCell( row, 1 ); + // Find the value column and the reference column if they're shown + int valueCol = -1; + int refCol = -1; + int anyCol = -1; + + for( int col = 0; col < m_dataModel->GetNumberCols(); col++ ) + { + if( m_dataModel->ColIsValue( col ) ) + valueCol = col; + else if( m_dataModel->ColIsReference( col ) ) + refCol = col; + else if( anyCol == -1 && m_dataModel->GetShowColumn( col ) ) + anyCol = col; + } + + if( valueCol != -1 && m_dataModel->GetShowColumn( valueCol ) ) + m_grid->GoToCell( row, valueCol ); + else if( refCol != -1 && m_dataModel->GetShowColumn( refCol ) ) + m_grid->GoToCell( row, refCol ); + else if( anyCol != -1 ) + m_grid->GoToCell( row, anyCol ); + break; } } } - UpdateScope(); - // We don't want table range selection events to happen until we've loaded the data or we // we'll clear our selection as the grid is built before the code above can get the // user's current selection. diff --git a/eeschema/fields_data_model.cpp b/eeschema/fields_data_model.cpp index 1b7b334669..2aa5d7610f 100644 --- a/eeschema/fields_data_model.cpp +++ b/eeschema/fields_data_model.cpp @@ -234,6 +234,12 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsReference( int aCol ) return m_cols[aCol].m_fieldName == TEMPLATE_FIELDNAME::GetDefaultFieldName( REFERENCE_FIELD ); } +bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsValue( int aCol ) +{ + wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false ); + return m_cols[aCol].m_fieldName == TEMPLATE_FIELDNAME::GetDefaultFieldName( VALUE_FIELD ); +} + bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsQuantity( int aCol ) { wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false ); diff --git a/eeschema/fields_data_model.h b/eeschema/fields_data_model.h index 9aed61f14d..9433246278 100644 --- a/eeschema/fields_data_model.h +++ b/eeschema/fields_data_model.h @@ -132,6 +132,7 @@ public: } bool ColIsReference( int aCol ); + bool ColIsValue( int aCol ); bool ColIsQuantity( int aCol ); bool ColIsItemNumber( int aCol ); bool ColIsAttribute( int aCol );