From 73ca5aff45a365cc35a8954e4b5486f3a6a300a4 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 1 Nov 2008 20:14:56 +0000 Subject: [PATCH] Fixed numerous problems in BWindow::_FindView: 1) If a view contained the point, but had children, that view would never be returned as a result, even if none of the children matched. 2) When converting coordinates to the child's coordinate space, it was using the bounds rectangle rather than the frame. This in most cases had the result that the coordinate was unchanged, and thus messed up the search completely. This fixes ticket #3000. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28440 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index a3bc3e91c0..033c1ca1dc 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -3507,19 +3507,21 @@ BWindow::_FindView(BView* view, BPoint point) const // point is assumed to be already in view's coordinates // TODO: since BView::Bounds() potentially queries the app_server anyway, // we could just let the app_server answer this query directly. - if (view->Bounds().Contains(point) && !view->fFirstChild) - return view; - - BView* child = view->fFirstChild; - - while (child != NULL) { - BPoint childPoint = point - child->LeftTop(); - if ((view = _FindView(child, childPoint)) != NULL) + if (view->Bounds().Contains(point)) { + if (!view->fFirstChild) return view; + else { + BView* child = view->fFirstChild; + while (child != NULL) { + BPoint childPoint = point - child->Frame().LeftTop(); + if ((view = _FindView(child, childPoint)) != NULL) + return view; + child = child->fNextSibling; + } + } - child = child->fNextSibling; + return view; } - return NULL; }