Promote to cell selection for spreadsheet-style paste.

Fixes https://gitlab.com/kicad/code/kicad/issues/9211
This commit is contained in:
Jeff Young
2021-12-24 16:29:23 +00:00
parent 3f90b3e2a0
commit 9de62d1dd4
3 changed files with 34 additions and 2 deletions
+32
View File
@@ -57,6 +57,7 @@ GRID_TRICKS::GRID_TRICKS( WX_GRID* aGrid ):
wxGridEventHandler( GRID_TRICKS::onGridLabelLeftClick ), nullptr, this );
aGrid->Connect( GRIDTRICKS_FIRST_ID, GRIDTRICKS_LAST_ID, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( GRID_TRICKS::onPopupSelection ), nullptr, this );
aGrid->Connect( wxEVT_CHAR_HOOK, wxCharEventHandler( GRID_TRICKS::onCharHook ), nullptr, this );
aGrid->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( GRID_TRICKS::onKeyDown ), nullptr, this );
aGrid->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( GRID_TRICKS::onUpdateUI ),
nullptr, this );
@@ -358,6 +359,37 @@ void GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
}
void GRID_TRICKS::onCharHook( wxKeyEvent& ev )
{
bool handled = false;
if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'V' )
{
if( m_grid->IsCellEditControlShown() && wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
{
wxTextDataObject data;
wxTheClipboard->GetData( data );
if( data.GetText().Contains( COL_SEP ) || data.GetText().Contains( ROW_SEP ) )
{
m_grid->CommitPendingChanges( true /* quiet mode */ );
paste_text( data.GetText() );
handled = true;
}
}
wxTheClipboard->Close();
m_grid->ForceRefresh();
}
}
if( !handled )
ev.Skip( true );
}
void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
{
if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'A' )