Merge WXK_HOME and WXK_END handling in a single case
There are more commonalities than differences between the handling of these 2 keys and it's better to have a single version of this code. No changes in behaviour.
This commit is contained in:
parent
c7707a16c7
commit
5b797618a1
@ -5563,71 +5563,66 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_HOME:
|
case WXK_HOME:
|
||||||
if ( m_currentCellCoords != wxGridNoCellCoords )
|
|
||||||
{
|
|
||||||
const bool useSelectedBlockCorner =
|
|
||||||
event.ShiftDown() && m_selectedBlockCorner != wxGridNoCellCoords;
|
|
||||||
int row = useSelectedBlockCorner ? m_selectedBlockCorner.GetRow()
|
|
||||||
: m_currentCellCoords.GetRow();
|
|
||||||
if ( event.ControlDown() )
|
|
||||||
{
|
|
||||||
row = 0;
|
|
||||||
|
|
||||||
// Find visible row.
|
|
||||||
for ( ; row < m_numRows; ++row )
|
|
||||||
{
|
|
||||||
if ( IsRowShown(row) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int col = 0;
|
|
||||||
// Find visible column.
|
|
||||||
for ( ; col < m_numCols; ++col )
|
|
||||||
{
|
|
||||||
if ( IsColShown(GetColAt(col)) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( event.ShiftDown() )
|
|
||||||
{
|
|
||||||
UpdateBlockBeingSelected(m_currentCellCoords,
|
|
||||||
wxGridCellCoords(row, col));
|
|
||||||
MakeCellVisible(row, col);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ClearSelection();
|
|
||||||
GoToCell(row, GetColAt(col));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WXK_END:
|
case WXK_END:
|
||||||
if ( m_currentCellCoords != wxGridNoCellCoords )
|
if ( m_currentCellCoords != wxGridNoCellCoords )
|
||||||
{
|
{
|
||||||
const bool useSelectedBlockCorner =
|
const bool goToBeginning = event.GetKeyCode() == WXK_HOME;
|
||||||
event.ShiftDown() && m_selectedBlockCorner != wxGridNoCellCoords;
|
|
||||||
int row = useSelectedBlockCorner ? m_selectedBlockCorner.GetRow()
|
// Find the first or last visible row if we need to go to it
|
||||||
: m_currentCellCoords.GetRow();
|
// (without Control, we keep the current row).
|
||||||
|
int row;
|
||||||
if ( event.ControlDown() )
|
if ( event.ControlDown() )
|
||||||
{
|
{
|
||||||
row = m_numRows - 1;
|
if ( goToBeginning )
|
||||||
|
|
||||||
// Find visible row.
|
|
||||||
for ( ; row >= 0; --row )
|
|
||||||
{
|
{
|
||||||
if ( IsRowShown(row) )
|
for ( row = 0; row < m_numRows; ++row )
|
||||||
break;
|
{
|
||||||
|
if ( IsRowShown(row) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( row = m_numRows - 1; row >= 0; --row )
|
||||||
|
{
|
||||||
|
if ( IsRowShown(row) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If we're selecting, continue in the same row, which
|
||||||
|
// may well be different from the one in which we
|
||||||
|
// started selecting.
|
||||||
|
if ( event.ShiftDown() &&
|
||||||
|
m_selectedBlockCorner != wxGridNoCellCoords )
|
||||||
|
{
|
||||||
|
row = m_selectedBlockCorner.GetRow();
|
||||||
|
}
|
||||||
|
else // Just use the current row.
|
||||||
|
{
|
||||||
|
row = m_currentCellCoords.GetRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int col = m_numCols - 1;
|
// Also find the last or first visible column in any case.
|
||||||
// Find visible column.
|
int col;
|
||||||
for ( ; col >= 0; --col )
|
if ( goToBeginning )
|
||||||
{
|
{
|
||||||
if ( IsColShown(GetColAt(col)) )
|
for ( col = 0; col < m_numCols; ++col )
|
||||||
break;
|
{
|
||||||
|
if ( IsColShown(GetColAt(col)) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( col = m_numCols - 1; col >= 0; --col )
|
||||||
|
{
|
||||||
|
if ( IsColShown(GetColAt(col)) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.ShiftDown() )
|
if ( event.ShiftDown() )
|
||||||
|
Loading…
Reference in New Issue
Block a user