Promote to cell selection for spreadsheet-style paste.
Fixes https://gitlab.com/kicad/code/kicad/issues/9211
This commit is contained in:
parent
3f90b3e2a0
commit
9de62d1dd4
|
@ -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' )
|
||||
|
|
|
@ -98,7 +98,6 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
|
|||
WX_GRID* aGrid, SCH_LABEL_BASE* aLabel ) :
|
||||
m_frame( aFrame ),
|
||||
m_dialog( aDialog ),
|
||||
m_userUnits( aDialog->GetUserUnits() ),
|
||||
m_grid( aGrid ),
|
||||
m_parentType( SCH_LABEL_LOCATE_ANY_T ),
|
||||
m_mandatoryFieldCount( aLabel->GetMandatoryFieldCount() ),
|
||||
|
|
|
@ -91,7 +91,8 @@ protected:
|
|||
void onGridLabelLeftClick( wxGridEvent& event );
|
||||
void onGridLabelRightClick( wxGridEvent& event );
|
||||
void onPopupSelection( wxCommandEvent& event );
|
||||
void onKeyDown( wxKeyEvent& ev );
|
||||
void onKeyDown( wxKeyEvent& event );
|
||||
void onCharHook( wxKeyEvent& event );
|
||||
void onUpdateUI( wxUpdateUIEvent& event );
|
||||
void onGridMotion( wxMouseEvent& event );
|
||||
|
||||
|
|
Loading…
Reference in New Issue