Fix position of the column after drag-move operation in wxGrid.
Fix the logic for finding the correct position to drop the column at when ending a drag move operation. The old code dropped it one position too far to the left when it was dropped on the "far" (i.e. right with LTR layout) part of the target column. See #16110. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3712,29 +3712,31 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
// get the position of the column we're over
|
// get the position of the column we're over
|
||||||
int pos = XToPos(x);
|
int pos = XToPos(x);
|
||||||
|
|
||||||
// we may need to adjust the drop position but don't bother
|
// insert the column being dragged either before or after
|
||||||
// checking for it if we can't anyhow
|
// it, depending on where exactly it was dropped, so
|
||||||
if ( pos > 1 )
|
// find the index of the column we're over: notice
|
||||||
{
|
// that the existing "col" variable may be invalid but
|
||||||
// also find the index of the column we're over: notice
|
// we need a valid one here
|
||||||
// that the existing "col" variable may be invalid but
|
const int colValid = GetColAt(pos);
|
||||||
// we need a valid one here
|
|
||||||
const int colValid = GetColAt(pos);
|
|
||||||
|
|
||||||
// if we're on the "near" (usually left but right in
|
// and check if we're on the "near" (usually left but right
|
||||||
// RTL case) part of the column, the actual position we
|
// in RTL case) part of the column
|
||||||
// should be placed in is actually the one before it
|
bool onNearPart;
|
||||||
bool onNearPart;
|
const int middle = GetColLeft(colValid) +
|
||||||
const int middle = GetColLeft(colValid) +
|
GetColWidth(colValid)/2;
|
||||||
GetColWidth(colValid)/2;
|
if ( GetLayoutDirection() == wxLayout_LeftToRight )
|
||||||
if ( GetLayoutDirection() == wxLayout_LeftToRight )
|
onNearPart = (x <= middle);
|
||||||
onNearPart = (x <= middle);
|
else // wxLayout_RightToLeft
|
||||||
else // wxLayout_RightToLeft
|
onNearPart = (x > middle);
|
||||||
onNearPart = (x > middle);
|
|
||||||
|
|
||||||
if ( onNearPart )
|
// adjust for the column being dragged itself
|
||||||
pos--;
|
if ( pos < GetColPos(m_dragRowOrCol) )
|
||||||
}
|
pos++;
|
||||||
|
|
||||||
|
// and if it's on the near part of the target column,
|
||||||
|
// insert it before it, not after
|
||||||
|
if ( onNearPart )
|
||||||
|
pos--;
|
||||||
|
|
||||||
DoEndMoveCol(pos);
|
DoEndMoveCol(pos);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user