From 75a438f9ac0303fec73b70d153c28b9a7269f121 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 Apr 2013 11:56:55 +0000 Subject: [PATCH] Really fix hit testing in the generic wxDataViewToggleRenderer. The changes of r73835 fixed hit testing in horizontal direction but broke it in the vertical one as the computed checkbox rectangle was not relative to the cell rectangle as it should have been. Do fix this now. See #15144. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index ba18a3bdea..3a29887b4b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1105,7 +1105,11 @@ bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& cellRect, // as this is how it's rendered, at least under MSW. If this turns out // to be a wrong assumption, we probably would need to do the hit test // checking in wxRendererNative but for now this simple solution works. - const wxRect checkRect = wxRect(GetSize()).CentreIn(cellRect); + wxRect checkRect = wxRect(GetSize()).CentreIn(cellRect); + + // After centering in cellRect, we need to pull it back to (0, 0) as + // the mouse coordinates passed to us are relative to cellRect already. + checkRect.Offset(-cellRect.GetPosition()); if ( !checkRect.Contains(mouseEvent->GetPosition()) ) return false;