Simplify and improve wxGrid::DoGridCellDrag() return value logic
Remove the "performDefault" variable which didn't really seem to help, as the actual meaning of the return value is whether we should start drag-selecting or not and the name of this variable didn't reflect this anyhow. Return false if we are over an invalid cell: this shouldn't change anything when we're already dragging, but would prevent us from starting to drag from an invalid cell which seems more correct, even if it's not clear if this can happen in practice. Also move hiding the edit control inside "isFirstDrag" check, there is no reason to do it on every drag.
This commit is contained in:
@@ -4471,29 +4471,24 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
|
||||
const wxGridCellCoords& coords,
|
||||
bool isFirstDrag)
|
||||
{
|
||||
bool performDefault = true ;
|
||||
|
||||
if ( coords == wxGridNoCellCoords )
|
||||
return performDefault; // we're outside any valid cell
|
||||
return false; // we're outside any valid cell
|
||||
|
||||
// Hide the edit control, so it won't interfere with drag-shrinking.
|
||||
if ( IsCellEditControlShown() )
|
||||
if ( isFirstDrag )
|
||||
{
|
||||
HideCellEditControl();
|
||||
SaveEditControlValue();
|
||||
}
|
||||
|
||||
if ( !event.HasAnyModifiers() )
|
||||
{
|
||||
if ( CanDragCell() )
|
||||
// Hide the edit control, so it won't interfere with drag-shrinking.
|
||||
if ( IsCellEditControlShown() )
|
||||
{
|
||||
if ( isFirstDrag )
|
||||
HideCellEditControl();
|
||||
SaveEditControlValue();
|
||||
}
|
||||
|
||||
if ( !event.HasAnyModifiers() )
|
||||
{
|
||||
if ( CanDragCell() )
|
||||
{
|
||||
// if event is handled by user code, no further processing
|
||||
if ( SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event) != 0 )
|
||||
performDefault = false;
|
||||
|
||||
return performDefault;
|
||||
return SendEvent(wxEVT_GRID_CELL_BEGIN_DRAG, coords, event) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4502,7 +4497,7 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
|
||||
if ( m_selection )
|
||||
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
|
||||
|
||||
return performDefault;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxGrid::DoGridDragEvent(wxMouseEvent& event,
|
||||
|
Reference in New Issue
Block a user