From 35bd8dbde8a798f61ad6d7cd0eb6220510d4b26b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Mar 2014 16:52:54 +0000 Subject: [PATCH] Fix clicking on activatable toggle column in generic wxDataViewCtrl. Call PrepareForItem() after calling GetLineStart() as the latter calls PrepareForItem() for other items internally, undoing the effects of the first call. Closes #16132. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76212 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/generic/datavgen.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 50a33da7c8..e01c1c7524 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -650,6 +650,7 @@ wxMSW: - Disable the use of new style wxDirDialog under Vista to work around a bug in its implementation under this system (jtrauntvein). - Fix wxExecute() keeping open too many thread handles for too long (dannchr). +- Fix clicking on togglable columns in wxDataViewCtrl (Laurent Poujoulat). - Fix expander in non left-most position in wxDataViewCtrl (Laurent Poujoulat). wxOSX: diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 2f14e6d964..338454e5de 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4398,13 +4398,17 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) if ( IsCellEditableInMode(item, col, wxDATAVIEW_CELL_ACTIVATABLE) ) { // notify cell about click - cell->PrepareForItem(model, item, col->GetModelColumn()); wxRect cell_rect( xpos + itemOffset, GetLineStart( current ), col->GetWidth() - itemOffset, GetLineHeight( current ) ); + // Note that PrepareForItem() should be called after GetLineStart() + // call in cell_rect initialization above as GetLineStart() calls + // PrepareForItem() for other items from inside it. + cell->PrepareForItem(model, item, col->GetModelColumn()); + // Report position relative to the cell's custom area, i.e. // not the entire space as given by the control but the one // used by the renderer after calculation of alignment etc.