Repaired semantics of EVT_GRID_SELECT_CELL.
Added OnKeyUp handler for selection with Shift+arrow keys. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1713,6 +1713,7 @@ protected:
|
|||||||
void OnPaint( wxPaintEvent& );
|
void OnPaint( wxPaintEvent& );
|
||||||
void OnSize( wxSizeEvent& );
|
void OnSize( wxSizeEvent& );
|
||||||
void OnKeyDown( wxKeyEvent& );
|
void OnKeyDown( wxKeyEvent& );
|
||||||
|
void OnKeyUp( wxKeyEvent& );
|
||||||
void OnEraseBackground( wxEraseEvent& );
|
void OnEraseBackground( wxEraseEvent& );
|
||||||
|
|
||||||
|
|
||||||
|
@@ -182,6 +182,7 @@ private:
|
|||||||
void OnPaint( wxPaintEvent &event );
|
void OnPaint( wxPaintEvent &event );
|
||||||
void OnMouseEvent( wxMouseEvent& event );
|
void OnMouseEvent( wxMouseEvent& event );
|
||||||
void OnKeyDown( wxKeyEvent& );
|
void OnKeyDown( wxKeyEvent& );
|
||||||
|
void OnKeyUp( wxKeyEvent& );
|
||||||
void OnEraseBackground( wxEraseEvent& );
|
void OnEraseBackground( wxEraseEvent& );
|
||||||
|
|
||||||
|
|
||||||
@@ -2987,6 +2988,7 @@ BEGIN_EVENT_TABLE( wxGridWindow, wxPanel )
|
|||||||
EVT_PAINT( wxGridWindow::OnPaint )
|
EVT_PAINT( wxGridWindow::OnPaint )
|
||||||
EVT_MOUSE_EVENTS( wxGridWindow::OnMouseEvent )
|
EVT_MOUSE_EVENTS( wxGridWindow::OnMouseEvent )
|
||||||
EVT_KEY_DOWN( wxGridWindow::OnKeyDown )
|
EVT_KEY_DOWN( wxGridWindow::OnKeyDown )
|
||||||
|
EVT_KEY_UP( wxGridWindow::OnKeyUp )
|
||||||
EVT_ERASE_BACKGROUND( wxGridWindow::OnEraseBackground )
|
EVT_ERASE_BACKGROUND( wxGridWindow::OnEraseBackground )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -3037,7 +3039,7 @@ void wxGridWindow::OnMouseEvent( wxMouseEvent& event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This seems to be required for wxMotif otherwise the mouse
|
// This seems to be required for wxMotif/wxGTK otherwise the mouse
|
||||||
// cursor must be in the cell edit control to get key events
|
// cursor must be in the cell edit control to get key events
|
||||||
//
|
//
|
||||||
void wxGridWindow::OnKeyDown( wxKeyEvent& event )
|
void wxGridWindow::OnKeyDown( wxKeyEvent& event )
|
||||||
@@ -3045,6 +3047,11 @@ void wxGridWindow::OnKeyDown( wxKeyEvent& event )
|
|||||||
if ( !m_owner->ProcessEvent( event ) ) event.Skip();
|
if ( !m_owner->ProcessEvent( event ) ) event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGridWindow::OnKeyUp( wxKeyEvent& event )
|
||||||
|
{
|
||||||
|
if ( !m_owner->ProcessEvent( event ) ) event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxGridWindow::OnEraseBackground( wxEraseEvent& WXUNUSED(event) )
|
void wxGridWindow::OnEraseBackground( wxEraseEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
@@ -3060,6 +3067,7 @@ BEGIN_EVENT_TABLE( wxGrid, wxScrolledWindow )
|
|||||||
EVT_PAINT( wxGrid::OnPaint )
|
EVT_PAINT( wxGrid::OnPaint )
|
||||||
EVT_SIZE( wxGrid::OnSize )
|
EVT_SIZE( wxGrid::OnSize )
|
||||||
EVT_KEY_DOWN( wxGrid::OnKeyDown )
|
EVT_KEY_DOWN( wxGrid::OnKeyDown )
|
||||||
|
EVT_KEY_UP( wxGrid::OnKeyUp )
|
||||||
EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground )
|
EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -5146,24 +5154,6 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
|
|
||||||
// try local handlers
|
// try local handlers
|
||||||
//
|
//
|
||||||
if ( !event.ShiftDown() &&
|
|
||||||
m_selectingKeyboard != wxGridNoCellCoords )
|
|
||||||
{
|
|
||||||
if ( m_selectingTopLeft != wxGridNoCellCoords &&
|
|
||||||
m_selectingBottomRight != wxGridNoCellCoords )
|
|
||||||
m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
|
|
||||||
m_selectingTopLeft.GetCol(),
|
|
||||||
m_selectingBottomRight.GetRow(),
|
|
||||||
m_selectingBottomRight.GetCol(),
|
|
||||||
event.ControlDown(),
|
|
||||||
event.ShiftDown(),
|
|
||||||
event.AltDown(),
|
|
||||||
event.MetaDown() );
|
|
||||||
m_selectingTopLeft = wxGridNoCellCoords;
|
|
||||||
m_selectingBottomRight = wxGridNoCellCoords;
|
|
||||||
m_selectingKeyboard = wxGridNoCellCoords;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ( event.KeyCode() )
|
switch ( event.KeyCode() )
|
||||||
{
|
{
|
||||||
case WXK_UP:
|
case WXK_UP:
|
||||||
@@ -5319,12 +5309,40 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
m_inOnKeyDown = FALSE;
|
m_inOnKeyDown = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGrid::OnKeyUp( wxKeyEvent& event )
|
||||||
|
{
|
||||||
|
// try local handlers
|
||||||
|
//
|
||||||
|
if ( event.KeyCode() == WXK_SHIFT )
|
||||||
|
{
|
||||||
|
if ( m_selectingTopLeft != wxGridNoCellCoords &&
|
||||||
|
m_selectingBottomRight != wxGridNoCellCoords )
|
||||||
|
m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
|
||||||
|
m_selectingTopLeft.GetCol(),
|
||||||
|
m_selectingBottomRight.GetRow(),
|
||||||
|
m_selectingBottomRight.GetCol(),
|
||||||
|
event.ControlDown(),
|
||||||
|
event.ShiftDown(),
|
||||||
|
event.AltDown(),
|
||||||
|
event.MetaDown() );
|
||||||
|
m_selectingTopLeft = wxGridNoCellCoords;
|
||||||
|
m_selectingBottomRight = wxGridNoCellCoords;
|
||||||
|
m_selectingKeyboard = wxGridNoCellCoords;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxGrid::OnEraseBackground(wxEraseEvent&)
|
void wxGrid::OnEraseBackground(wxEraseEvent&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
||||||
{
|
{
|
||||||
|
if ( SendEvent( wxEVT_GRID_SELECT_CELL, coords.GetRow(), coords.GetCol() ) )
|
||||||
|
{
|
||||||
|
// the event has been intercepted - do nothing
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_currentCellCoords != wxGridNoCellCoords )
|
if ( m_currentCellCoords != wxGridNoCellCoords )
|
||||||
{
|
{
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
|
@@ -540,11 +540,11 @@ void wxGridSelection::SelectCell( int row, int col,
|
|||||||
// Send event
|
// Send event
|
||||||
if (sendEvent)
|
if (sendEvent)
|
||||||
{
|
{
|
||||||
wxGridEvent gridEvt( m_grid->GetId(),
|
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
||||||
wxEVT_GRID_SELECT_CELL,
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
m_grid,
|
m_grid,
|
||||||
row, col,
|
wxGridCellCoords( row, col ),
|
||||||
-1, -1,
|
wxGridCellCoords( row, col ),
|
||||||
TRUE,
|
TRUE,
|
||||||
ControlDown, ShiftDown,
|
ControlDown, ShiftDown,
|
||||||
AltDown, MetaDown);
|
AltDown, MetaDown);
|
||||||
@@ -590,10 +590,12 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
|
|||||||
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
|
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
|
||||||
|
|
||||||
// Send event
|
// Send event
|
||||||
wxGridEvent gridEvt( m_grid->GetId(),
|
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
||||||
wxEVT_GRID_SELECT_CELL,
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
m_grid,
|
m_grid,
|
||||||
row, col, -1, -1, FALSE,
|
wxGridCellCoords( row, col ),
|
||||||
|
wxGridCellCoords( row, col ),
|
||||||
|
FALSE,
|
||||||
ControlDown, ShiftDown,
|
ControlDown, ShiftDown,
|
||||||
AltDown, MetaDown );
|
AltDown, MetaDown );
|
||||||
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
|
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
@@ -714,10 +716,12 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
|
|||||||
wxGridCellCoords( row, col ) );
|
wxGridCellCoords( row, col ) );
|
||||||
if ( !m_grid->GetBatchCount() )
|
if ( !m_grid->GetBatchCount() )
|
||||||
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
|
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
|
||||||
wxGridEvent gridEvt( m_grid->GetId(),
|
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
|
||||||
wxEVT_GRID_SELECT_CELL,
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
m_grid,
|
m_grid,
|
||||||
row, col, -1, -1, FALSE,
|
wxGridCellCoords( row, col ),
|
||||||
|
wxGridCellCoords( row, col ),
|
||||||
|
FALSE,
|
||||||
ControlDown, ShiftDown,
|
ControlDown, ShiftDown,
|
||||||
AltDown, MetaDown );
|
AltDown, MetaDown );
|
||||||
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
|
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
|
Reference in New Issue
Block a user