Fix bug with dragging non-draggable columns in wxMSW wxHeaderCtrl.
Properly ignore HDN_BEGINDRAG events for the columns without wxCOL_REORDERABLE flag. This fixes dragging non-draggable columns in wxDataViewCtrl under MSW. Closes #14940. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73389 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -602,6 +602,7 @@ All (GUI):
|
|||||||
- Add "rect" paramerer to wxRichToolTip::ShowFor() (John Roberts).
|
- Add "rect" paramerer to wxRichToolTip::ShowFor() (John Roberts).
|
||||||
- Add wxListCtrl::EnableAlternateRowColours() (troelsk).
|
- Add wxListCtrl::EnableAlternateRowColours() (troelsk).
|
||||||
- Fix wrong tab order in wxAuiNotebook after dragging (Mark Barber).
|
- Fix wrong tab order in wxAuiNotebook after dragging (Mark Barber).
|
||||||
|
- Fix bug in generic wxDataViewCtrl column dragging (jobuz).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -127,6 +127,9 @@ private:
|
|||||||
// the offset of the window used to emulate scrolling it
|
// the offset of the window used to emulate scrolling it
|
||||||
int m_scrollOffset;
|
int m_scrollOffset;
|
||||||
|
|
||||||
|
// actual column we are dragging or -1 if not dragging anything
|
||||||
|
int m_colBeingDragged;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl);
|
wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -64,6 +64,7 @@ void wxHeaderCtrl::Init()
|
|||||||
m_numColumns = 0;
|
m_numColumns = 0;
|
||||||
m_imageList = NULL;
|
m_imageList = NULL;
|
||||||
m_scrollOffset = 0;
|
m_scrollOffset = 0;
|
||||||
|
m_colBeingDragged = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxHeaderCtrl::Create(wxWindow *parent,
|
bool wxHeaderCtrl::Create(wxWindow *parent,
|
||||||
@@ -525,6 +526,9 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
case HDN_ITEMCLICK:
|
case HDN_ITEMCLICK:
|
||||||
case HDN_ITEMDBLCLICK:
|
case HDN_ITEMDBLCLICK:
|
||||||
evtType = GetClickEventType(code == HDN_ITEMDBLCLICK, nmhdr->iButton);
|
evtType = GetClickEventType(code == HDN_ITEMDBLCLICK, nmhdr->iButton);
|
||||||
|
|
||||||
|
// We're not dragging any more.
|
||||||
|
m_colBeingDragged = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// although we should get the notifications about the right clicks
|
// although we should get the notifications about the right clicks
|
||||||
@@ -622,8 +626,18 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
if ( nmhdr->iItem == -1 )
|
if ( nmhdr->iItem == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// If we are dragging a column that is not draggable and the mouse
|
||||||
|
// is moved over a different column then we get the column number from
|
||||||
|
// the column under the mouse. This results in an unexpected behaviour
|
||||||
|
// if this column is draggable. To prevent this remember the column we
|
||||||
|
// are dragging for the complete drag and drop cycle.
|
||||||
|
if ( m_colBeingDragged == -1 )
|
||||||
|
{
|
||||||
|
m_colBeingDragged = idx;
|
||||||
|
}
|
||||||
|
|
||||||
// column must have the appropriate flag to be draggable
|
// column must have the appropriate flag to be draggable
|
||||||
if ( !GetColumn(idx).IsReorderable() )
|
if ( !GetColumn(m_colBeingDragged).IsReorderable() )
|
||||||
{
|
{
|
||||||
veto = true;
|
veto = true;
|
||||||
break;
|
break;
|
||||||
@@ -644,10 +658,16 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
order = MSWFromNativeOrder(order);
|
order = MSWFromNativeOrder(order);
|
||||||
|
|
||||||
evtType = wxEVT_COMMAND_HEADER_END_REORDER;
|
evtType = wxEVT_COMMAND_HEADER_END_REORDER;
|
||||||
|
|
||||||
|
// We (successfully) ended dragging the column.
|
||||||
|
m_colBeingDragged = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NM_RELEASEDCAPTURE:
|
case NM_RELEASEDCAPTURE:
|
||||||
evtType = wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED;
|
evtType = wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED;
|
||||||
|
|
||||||
|
// Dragging the column was cancelled.
|
||||||
|
m_colBeingDragged = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user