Class used to create a set of options to pass to the show() method. More...
#include <juce_PopupMenu.h>
Public Types | |
enum | PopupDirection { PopupDirection::upwards, PopupDirection::downwards } |
Public Member Functions | |
Options () | |
By default, the target screen area will be the current mouse position. More... | |
Options (const Options &)=default | |
int | getInitiallySelectedItemId () const noexcept |
Gets the ID of the item that must be selected when the menu is initially shown. More... | |
int | getItemThatMustBeVisible () const noexcept |
Gets the ID of the item that must be visible when the menu is initially shown. More... | |
int | getMaximumNumColumns () const noexcept |
Gets the maximum number of columns. More... | |
int | getMinimumNumColumns () const noexcept |
Gets the minimum number of columns. More... | |
int | getMinimumWidth () const noexcept |
Gets the minimum width. More... | |
Component * | getParentComponent () const noexcept |
Gets the parent component. More... | |
PopupDirection | getPreferredPopupDirection () const noexcept |
Gets the preferred popup menu direction. More... | |
int | getStandardItemHeight () const noexcept |
Gets the default height of items in the menu. More... | |
Component * | getTargetComponent () const noexcept |
Gets the target component. More... | |
Rectangle< int > | getTargetScreenArea () const noexcept |
Gets the target screen area. More... | |
bool | hasWatchedComponentBeenDeleted () const noexcept |
Returns true if the menu was watching a component, and that component has been deleted, and false otherwise. More... | |
Options & | operator= (const Options &)=default |
JUCE_NODISCARD Options | withDeletionCheck (Component &componentToWatchForDeletion) const |
If the passed component has been deleted when the popup menu exits, the selected item's action will not be called. More... | |
JUCE_NODISCARD Options | withInitiallySelectedItem (int idOfItemToBeSelected) const |
Sets an item to select in the menu. More... | |
JUCE_NODISCARD Options | withItemThatMustBeVisible (int idOfItemToBeVisible) const |
Sets an item which must be visible when the menu is initially drawn. More... | |
JUCE_NODISCARD Options | withMaximumNumColumns (int maxNumColumns) const |
Sets the maximum number of columns in the popup window. More... | |
JUCE_NODISCARD Options | withMinimumNumColumns (int minNumColumns) const |
Sets the minimum number of columns in the popup window. More... | |
JUCE_NODISCARD Options | withMinimumWidth (int minWidth) const |
Sets the minimum width of the popup window. More... | |
JUCE_NODISCARD Options | withMousePosition () const |
Sets the target screen area to match the current mouse position. More... | |
JUCE_NODISCARD Options | withParentComponent (Component *parentComponent) const |
Sets a component that the popup menu will be drawn into. More... | |
JUCE_NODISCARD Options | withPreferredPopupDirection (PopupDirection direction) const |
Sets the direction of the popup menu relative to the target screen area. More... | |
JUCE_NODISCARD Options | withStandardItemHeight (int standardHeight) const |
Sets the default height of each item in the popup menu. More... | |
JUCE_NODISCARD Options | withTargetComponent (Component &targetComponent) const |
JUCE_NODISCARD Options | withTargetComponent (Component *targetComponent) const |
Sets the target component to use when displaying the menu. More... | |
JUCE_NODISCARD Options | withTargetScreenArea (Rectangle< int > targetArea) const |
Sets the region of the screen next to which the menu should be displayed. More... | |
Private Attributes | |
WeakReference< Component > | componentToWatchForDeletion |
int | initiallySelectedItemId = 0 |
bool | isWatchingForDeletion = false |
int | maxColumns = 0 |
int | minColumns = 1 |
int | minWidth = 0 |
WeakReference< Component > | parentComponent |
PopupDirection | preferredPopupDirection = PopupDirection::downwards |
int | standardHeight = 0 |
Rectangle< int > | targetArea |
WeakReference< Component > | targetComponent |
int | visibleItemID = 0 |
Class used to create a set of options to pass to the show() method.
You can chain together a series of calls to this class's methods to create a set of whatever options you want to specify. E.g.
|
strong |
juce::PopupMenu::Options::Options | ( | ) |
By default, the target screen area will be the current mouse position.
|
default |
|
inlinenoexcept |
Gets the ID of the item that must be selected when the menu is initially shown.
|
inlinenoexcept |
Gets the ID of the item that must be visible when the menu is initially shown.
|
inlinenoexcept |
Gets the maximum number of columns.
|
inlinenoexcept |
Gets the minimum number of columns.
|
inlinenoexcept |
Gets the minimum width.
|
inlinenoexcept |
Gets the parent component.
This may be nullptr if the Component has been deleted.
|
inlinenoexcept |
Gets the preferred popup menu direction.
|
inlinenoexcept |
Gets the default height of items in the menu.
|
inlinenoexcept |
Gets the target component.
This may be nullptr if the Component has been deleted.
Gets the target screen area.
|
inlinenoexcept |
Returns true if the menu was watching a component, and that component has been deleted, and false otherwise.
JUCE_NODISCARD Options juce::PopupMenu::Options::withDeletionCheck | ( | Component & | componentToWatchForDeletion | ) | const |
If the passed component has been deleted when the popup menu exits, the selected item's action will not be called.
This is useful for avoiding dangling references inside the action callback, in the case that the callback needs to access a component that may be deleted.
JUCE_NODISCARD Options juce::PopupMenu::Options::withInitiallySelectedItem | ( | int | idOfItemToBeSelected | ) | const |
Sets an item to select in the menu.
This is useful for controls such as combo boxes, where opening the combo box with the keyboard should ideally highlight the currently-selected item, allowing the next/previous item to be selected by pressing up/down on the keyboard, rather than needing to move the highlighted row down from the top of the menu each time it is opened.
JUCE_NODISCARD Options juce::PopupMenu::Options::withItemThatMustBeVisible | ( | int | idOfItemToBeVisible | ) | const |
Sets an item which must be visible when the menu is initially drawn.
This is useful to ensure that a particular item is shown when the menu contains too many items to display on a single screen.
JUCE_NODISCARD Options juce::PopupMenu::Options::withMaximumNumColumns | ( | int | maxNumColumns | ) | const |
Sets the maximum number of columns in the popup window.
JUCE_NODISCARD Options juce::PopupMenu::Options::withMinimumNumColumns | ( | int | minNumColumns | ) | const |
Sets the minimum number of columns in the popup window.
JUCE_NODISCARD Options juce::PopupMenu::Options::withMinimumWidth | ( | int | minWidth | ) | const |
Sets the minimum width of the popup window.
JUCE_NODISCARD Options juce::PopupMenu::Options::withMousePosition | ( | ) | const |
Sets the target screen area to match the current mouse position.
Make sure to call this after withTargetComponent().
JUCE_NODISCARD Options juce::PopupMenu::Options::withParentComponent | ( | Component * | parentComponent | ) | const |
Sets a component that the popup menu will be drawn into.
Some plugin formats, such as AUv3, dislike it when the plugin editor spawns additional windows. Some AUv3 hosts display pink backgrounds underneath transparent popup windows, which is confusing and can appear as though the plugin is malfunctioning. Setting a parent component will avoid this unwanted behaviour, but with the downside that the menu size will be constrained by the size of the parent component.
JUCE_NODISCARD Options juce::PopupMenu::Options::withPreferredPopupDirection | ( | PopupDirection | direction | ) | const |
Sets the direction of the popup menu relative to the target screen area.
JUCE_NODISCARD Options juce::PopupMenu::Options::withStandardItemHeight | ( | int | standardHeight | ) | const |
Sets the default height of each item in the popup menu.
JUCE_NODISCARD Options juce::PopupMenu::Options::withTargetComponent | ( | Component & | targetComponent | ) | const |
JUCE_NODISCARD Options juce::PopupMenu::Options::withTargetComponent | ( | Component * | targetComponent | ) | const |
Sets the target component to use when displaying the menu.
This is normally the button or other control that triggered the menu.
The target component is primarily used to control the scale of the menu, so it's important to supply a target component if you'll be using your program on hi-DPI displays.
This function will also set the target screen area, so that the menu displays next to the target component. If you need to display the menu at a specific location, you should call withTargetScreenArea() after withTargetComponent.
JUCE_NODISCARD Options juce::PopupMenu::Options::withTargetScreenArea | ( | Rectangle< int > | targetArea | ) | const |
Sets the region of the screen next to which the menu should be displayed.
To display the menu next to the mouse cursor use withMousePosition(), which is equivalent to passing the following to this function:
withTargetComponent() will also set the target screen area. If you need a target component and a target screen area, make sure to call withTargetScreenArea() after withTargetComponent().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |