From 511e01c400208881d55f9be5adde8dcd9802d566 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 16 Jul 2018 16:15:24 +0100 Subject: [PATCH] Ensure that the target point in MenuWindow::getParentArea() is always in terms of screen coordinates --- modules/juce_gui_basics/menus/juce_PopupMenu.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 204ade9a38..d386cd44f2 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -592,8 +592,11 @@ struct MenuWindow : public Component } //============================================================================== - Rectangle getParentArea (Point targetPoint) + Rectangle getParentArea (Point targetPoint, Component* relativeTo = nullptr) { + if (relativeTo != nullptr) + targetPoint = relativeTo->localPointToGlobal (targetPoint); + auto parentArea = Desktop::getInstance().getDisplays().getDisplayContaining (targetPoint) #if JUCE_MAC .userArea; @@ -789,7 +792,7 @@ struct MenuWindow : public Component windowPos.getHeight() - (PopupMenuSettings::scrollZone + m->getHeight())), currentY); - auto parentArea = getParentArea (windowPos.getPosition()) / scaleFactor; + auto parentArea = getParentArea (windowPos.getPosition(), parentComponent) / scaleFactor; auto deltaY = wantedY - currentY; windowPos.setSize (jmin (windowPos.getWidth(), parentArea.getWidth()),