@@ -1713,7 +1713,8 @@ private: | |||||
if (e.mods.isRightButtonDown()) | if (e.mods.isRightButtonDown()) | ||||
if (auto* c = editor.getHostContext()) | if (auto* c = editor.getHostContext()) | ||||
if (auto menuInfo = c->getContextMenuForParameterIndex (¶m)) | if (auto menuInfo = c->getContextMenuForParameterIndex (¶m)) | ||||
menuInfo->getEquivalentPopupMenu().showMenuAsync ({}); | |||||
menuInfo->getEquivalentPopupMenu().showMenuAsync (PopupMenu::Options{}.withTargetComponent (this) | |||||
.withMousePosition()); | |||||
} | } | ||||
private: | private: | ||||
@@ -450,16 +450,11 @@ public: | |||||
if (e.mods.isRightButtonDown()) | if (e.mods.isRightButtonDown()) | ||||
if (auto* context = editor.getHostContext()) | if (auto* context = editor.getHostContext()) | ||||
if (auto menu = context->getContextMenuForParameterIndex (¶meter)) | if (auto menu = context->getContextMenuForParameterIndex (¶meter)) | ||||
menu->getEquivalentPopupMenu().showMenuAsync (getMenuOptions()); | |||||
menu->getEquivalentPopupMenu().showMenuAsync (PopupMenu::Options().withTargetComponent (this) | |||||
.withMousePosition()); | |||||
} | } | ||||
private: | private: | ||||
PopupMenu::Options getMenuOptions() | |||||
{ | |||||
return PopupMenu::Options().withTargetComponent (this) | |||||
.withTargetScreenArea ({ Desktop::getMousePosition(), Desktop::getMousePosition() }); | |||||
} | |||||
AudioProcessorEditor& editor; | AudioProcessorEditor& editor; | ||||
AudioProcessorParameter& parameter; | AudioProcessorParameter& parameter; | ||||
Label parameterName, parameterLabel; | Label parameterName, parameterLabel; | ||||
@@ -1927,6 +1927,11 @@ PopupMenu::Options PopupMenu::Options::withTargetScreenArea (Rectangle<int> area | |||||
return with (*this, &Options::targetArea, area); | return with (*this, &Options::targetArea, area); | ||||
} | } | ||||
PopupMenu::Options PopupMenu::Options::withMousePosition() const | |||||
{ | |||||
return withTargetScreenArea (Rectangle<int>{}.withPosition (Desktop::getMousePosition())); | |||||
} | |||||
PopupMenu::Options PopupMenu::Options::withDeletionCheck (Component& comp) const | PopupMenu::Options PopupMenu::Options::withDeletionCheck (Component& comp) const | ||||
{ | { | ||||
return with (with (*this, &Options::isWatchingForDeletion, true), | return with (with (*this, &Options::isWatchingForDeletion, true), | ||||
@@ -480,15 +480,28 @@ public: | |||||
/** Sets the region of the screen next to which the menu should be displayed. | /** Sets the region of the screen next to which the menu should be displayed. | ||||
To display the menu next to the mouse cursor, pass | |||||
Rectangle<int>{}.withPosition (Desktop::getMousePosition()). | |||||
To display the menu next to the mouse cursor use withMousePosition(), | |||||
which is equivalent to passing the following to this function: | |||||
@code | |||||
Rectangle<int>{}.withPosition (Desktop::getMousePosition()) | |||||
@endcode | |||||
withTargetComponent() will also set the target screen area. If you need | withTargetComponent() will also set the target screen area. If you need | ||||
a target component and a target screen area, make sure to call | a target component and a target screen area, make sure to call | ||||
withTargetScreenArea() after withTargetComponent(). | withTargetScreenArea() after withTargetComponent(). | ||||
@see withMousePosition | |||||
*/ | */ | ||||
Options withTargetScreenArea (Rectangle<int> targetArea) const; | Options withTargetScreenArea (Rectangle<int> targetArea) const; | ||||
/** Sets the target screen area to match the current mouse position. | |||||
Make sure to call this after withTargetComponent(). | |||||
@see withTargetScreenArea | |||||
*/ | |||||
Options withMousePosition() const; | |||||
/** If the passed component has been deleted when the popup menu exits, | /** If the passed component has been deleted when the popup menu exits, | ||||
the selected item's action will not be called. | the selected item's action will not be called. | ||||