Hook up AddField handler to GRID_TRICKS for SCH dialogs.

Fixes https://gitlab.com/kicad/code/kicad/issues/git/14153
This commit is contained in:
Jeff Young 2023-03-02 17:50:39 +00:00
parent 7638e23ff1
commit f41f04b301
7 changed files with 32 additions and 14 deletions

View File

@ -464,6 +464,7 @@ void GRID_TRICKS::onCharHook( wxKeyEvent& ev )
{
wxCommandEvent dummy;
m_addHandler( dummy );
handled = true;
}
}
else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'V' )

View File

@ -110,7 +110,11 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_L
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
m_grid->SetTable( m_fields );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this,
[&]( wxCommandEvent& aEvent )
{
OnAddField( aEvent );
} ) );
m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
// Show/hide columns according to user's preference
@ -603,7 +607,7 @@ void DIALOG_LABEL_PROPERTIES::OnAddField( wxCommandEvent& event )
if( !m_grid->CommitPendingChanges() )
return;
int fieldID = m_fields->size();
int fieldID = (int) m_fields->size();
wxString fieldName;
if( (int) fieldID == m_currentLabel->GetMandatoryFieldCount()
@ -637,8 +641,8 @@ void DIALOG_LABEL_PROPERTIES::OnAddField( wxCommandEvent& event )
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
m_grid->ProcessTableMessage( msg );
m_grid->MakeCellVisible( m_fields->size() - 1, 0 );
m_grid->SetGridCursor( m_fields->size() - 1, fieldName == wxT( "Netclass" ) ? 1 : 0 );
m_grid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
m_grid->SetGridCursor( (int) m_fields->size() - 1, 0 );
m_grid->EnableCellEditControl();
m_grid->ShowCellEditControl();

View File

@ -65,7 +65,11 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_grid, m_libEntry );
m_grid->SetTable( m_fields );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this,
[&]( wxCommandEvent& aEvent )
{
OnAddField( aEvent );
} ) );
m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
// Show/hide columns according to the user's preference

View File

@ -61,7 +61,11 @@ DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
m_grid->SetTable( m_fields );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this,
[&]( wxCommandEvent& aEvent )
{
OnAddField( aEvent );
} ) );
m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
// Show/hide columns according to user's preference

View File

@ -325,7 +325,11 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
m_pinGrid->SetDefaultRowSize( m_pinGrid->GetDefaultRowSize() + 4 );
m_fieldsGrid->SetTable( m_fields );
m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this ) );
m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this,
[&]( wxCommandEvent& aEvent )
{
OnAddField( aEvent );
} ) );
m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
// Show/hide columns according to user's preference

View File

@ -38,8 +38,9 @@ class SCH_LABEL_BASE;
class FIELDS_GRID_TRICKS : public GRID_TRICKS
{
public:
FIELDS_GRID_TRICKS( WX_GRID* aGrid, DIALOG_SHIM* aDialog ) :
GRID_TRICKS( aGrid ),
FIELDS_GRID_TRICKS( WX_GRID* aGrid, DIALOG_SHIM* aDialog,
std::function<void( wxCommandEvent& )> aAddHandler ) :
GRID_TRICKS( aGrid, std::move( aAddHandler ) ),
m_dlg( aDialog )
{}

View File

@ -142,17 +142,17 @@ bool SCH_FIELD_VALIDATOR::Validate( wxWindow* aParent )
{
wxArrayString badCharsFound;
for( const wxString& excludeChar : GetExcludes() )
for( const wxUniCharRef& excludeChar : GetCharExcludes() )
{
if( val.Find( excludeChar ) != wxNOT_FOUND )
{
if( excludeChar == wxT( "\r" ) )
if( excludeChar == '\r' )
badCharsFound.Add( _( "carriage return" ) );
else if( excludeChar == wxT( "\n" ) )
else if( excludeChar == '\n' )
badCharsFound.Add( _( "line feed" ) );
else if( excludeChar == wxT( "\t" ) )
else if( excludeChar == '\t' )
badCharsFound.Add( _( "tab" ) );
else if( excludeChar == wxT( " " ) )
else if( excludeChar == ' ' )
badCharsFound.Add( _( "space" ) );
else
badCharsFound.Add( wxString::Format( wxT( "'%s'" ), excludeChar ) );