From 35f1cb417b550eb5bfcebde1fac02cd4d1c4a4a6 Mon Sep 17 00:00:00 2001 From: Anton Triest Date: Sun, 3 May 2020 19:55:39 +0200 Subject: [PATCH] Fix hit testing in generic wxTreeCtrl in high DPI Update the code doing hit testing to use FromDIP() too, to be consistent with the changes of 3a9b5001ce (Fix size of wxGenericTreeCtrl buttons when using high DPI, 2020-02-23) # Please enter the commit message for your changes. Lines starting. See #18674. Closes #18749. --- src/generic/treectlg.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 4a2161f84d..9c92f35100 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -692,13 +692,16 @@ wxGenericTreeItem *wxGenericTreeItem::HitTest(const wxPoint& point, #ifdef __WXMAC__ // according to the drawing code the triangels are drawn // at -4 , -4 from the position up to +10/+10 max - if ((point.x > xCross-4) && (point.x < xCross+10) && - (point.y > y_mid-4) && (point.y < y_mid+10) && + const int triangleStart = theCtrl->FromDIP(4); + const int triangleEnd = theCtrl->FromDIP(10); + if ((point.x > xCross - triangleStart) && (point.x < xCross + triangleEnd) && + (point.y > y_mid - triangleStart) && (point.y < y_mid + triangleEnd) && HasPlus() && theCtrl->HasButtons() ) #else // 5 is the size of the plus sign - if ((point.x > xCross-6) && (point.x < xCross+6) && - (point.y > y_mid-6) && (point.y < y_mid+6) && + const int plusSize = 1 + theCtrl->FromDIP(5); + if ((point.x > xCross - plusSize) && (point.x < xCross + plusSize) && + (point.y > y_mid - plusSize) && (point.y < y_mid + plusSize) && HasPlus() && theCtrl->HasButtons() ) #endif {