Implement alternative solution to Ctrl-drag problem
This commit doesn't change the behaviour compared to the previous one, but provides an alternative implementation of the same goal, which seems preferable: instead of not extending the selection while Ctrl-dragging, just don't enter dragging mode, i.e. don't capture the mouse and don't set m_isDragging to true, if we start it from a previously selected, and hence currently deselected, cell.
This commit is contained in:
@@ -4483,31 +4483,36 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
|
|||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !event.HasAnyModifiers() )
|
switch ( event.GetModifiers() )
|
||||||
{
|
{
|
||||||
if ( CanDragCell() )
|
case wxMOD_CONTROL:
|
||||||
{
|
// Ctrl-dragging is special, because we could have started it
|
||||||
// if event is handled by user code, no further processing
|
// by Ctrl-clicking a previously selected cell, which has the
|
||||||
return SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event) == 0;
|
// effect of deselecting it and in this case we can't start
|
||||||
}
|
// drag-selection from it because the selection anchor should
|
||||||
|
// always be selected itself.
|
||||||
|
if ( !m_selection->IsInSelection(m_currentCellCoords) )
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
|
||||||
// When Shift-dragging, we must have already selected the initial
|
case wxMOD_NONE:
|
||||||
// cell and when Ctrl-dragging we may have either selected or
|
if ( CanDragCell() )
|
||||||
// deselected it, depending on its previous state. But when
|
{
|
||||||
// dragging without any modifiers, we want it to start in the
|
// if event is handled by user code, no further processing
|
||||||
// selected state even though it's not selected on a simple click.
|
return SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event) == 0;
|
||||||
if ( m_selection )
|
}
|
||||||
m_selection->SelectBlock(m_currentCellCoords, coords, event);
|
break;
|
||||||
|
|
||||||
|
//default: In all the other cases, we don't have anything special
|
||||||
|
// to do and we'll just extend the selection below.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend the selection if possible: this is not the case if we're dragging
|
// Note that we don't need to check the modifiers here, it doesn't matter
|
||||||
// from an unselected cell, as can be the case if the drag was started by
|
// which keys are pressed for the current event, as pressing or releasing
|
||||||
// Ctrl-clicking a previously selected cell (notice that the modifier of
|
// Ctrl later can't change the dragging behaviour. Only the initial state
|
||||||
// the current event is irrelevant, it's too late to change the behaviour
|
// of the modifier keys matters.
|
||||||
// by pressing or releasing Ctrl later, only its initial state, as
|
if ( m_selection )
|
||||||
// indicated by the state of the starting cell, counts).
|
|
||||||
if ( m_selection && m_selection->IsInSelection(m_currentCellCoords) )
|
|
||||||
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
|
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user