WX_GRID: highlight the selected cell after selection by tab or arrow keys.

Fixes #9290
https://gitlab.com/kicad/code/kicad/issues/9290
This commit is contained in:
jean-pierre charras 2022-02-04 12:36:27 +01:00
parent ad15cdfe99
commit ac7cbcce61
2 changed files with 16 additions and 0 deletions

View File

@ -96,11 +96,25 @@ void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
delete[] formBuilderColWidths;
Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
m_weOwnTable = aTakeOwnership;
}
void WX_GRID::onGridCellSelect( wxGridEvent& aEvent )
{
// Highlight the selected cell.
// Calling SelectBlock() allows a visual effect when cells are selected
// by tab or arrow keys.
// Otherwise, one cannot really know what actual cell is selected
int row = aEvent.GetRow();
int col = aEvent.GetCol();
if( row >= 0 && col >= 0 )
SelectBlock(row,col,row,col,false);
}
void WX_GRID::DestroyTable( wxGridTableBase* aTable )
{
// wxGrid's destructor will crash trying to look up the cell attr if the edit control
@ -108,6 +122,7 @@ void WX_GRID::DestroyTable( wxGridTableBase* aTable )
CommitPendingChanges( true /* quiet mode */ );
Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this );
wxGrid::SetTable( nullptr );
delete aTable;

View File

@ -117,6 +117,7 @@ protected:
void DrawColLabel( wxDC& dc, int col ) override;
void onGridColMove( wxGridEvent& aEvent );
void onGridCellSelect( wxGridEvent& aEvent );
bool m_weOwnTable;
};