JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
juce::PopupMenu::Options Class Reference

Class used to create a set of options to pass to the show() method. More...

#include "juce_PopupMenu.h"

Public Types

enum class  PopupDirection { upwards , downwards }
 

Public Member Functions

 Options ()
 By default, the target screen area will be the current mouse position.
 
 Options (const Options &)=default
 
Optionsoperator= (const Options &)=default
 
Options withTargetComponent (Component *targetComponent) const
 Sets the target component to use when displaying the menu.
 
Options withTargetComponent (Component &targetComponent) const
 
Options withTargetScreenArea (Rectangle< int > targetArea) const
 Sets the region of the screen next to which the menu should be displayed.
 
Options withMousePosition () const
 Sets the target screen area to match the current mouse position.
 
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.
 
Options withMinimumWidth (int minWidth) const
 Sets the minimum width of the popup window.
 
Options withMinimumNumColumns (int minNumColumns) const
 Sets the minimum number of columns in the popup window.
 
Options withMaximumNumColumns (int maxNumColumns) const
 Sets the maximum number of columns in the popup window.
 
Options withStandardItemHeight (int standardHeight) const
 Sets the default height of each item in the popup menu.
 
Options withItemThatMustBeVisible (int idOfItemToBeVisible) const
 Sets an item which must be visible when the menu is initially drawn.
 
Options withParentComponent (Component *parentComponent) const
 Sets a component that the popup menu will be drawn into.
 
Options withPreferredPopupDirection (PopupDirection direction) const
 Sets the direction of the popup menu relative to the target screen area.
 
Options withInitiallySelectedItem (int idOfItemToBeSelected) const
 Sets an item to select in the menu.
 
Options forSubmenu () const
 Returns a copy of these options with the target component set to null.
 
ComponentgetParentComponent () const noexcept
 Gets the parent component.
 
ComponentgetTargetComponent () const noexcept
 Gets the target component.
 
ComponentgetTopLevelTargetComponent () const noexcept
 Gets the target component that was set for the top-level menu.
 
bool hasWatchedComponentBeenDeleted () const noexcept
 Returns true if the menu was watching a component, and that component has been deleted, and false otherwise.
 
Rectangle< intgetTargetScreenArea () const noexcept
 Gets the target screen area.
 
int getMinimumWidth () const noexcept
 Gets the minimum width.
 
int getMaximumNumColumns () const noexcept
 Gets the maximum number of columns.
 
int getMinimumNumColumns () const noexcept
 Gets the minimum number of columns.
 
int getStandardItemHeight () const noexcept
 Gets the default height of items in the menu.
 
int getItemThatMustBeVisible () const noexcept
 Gets the ID of the item that must be visible when the menu is initially shown.
 
PopupDirection getPreferredPopupDirection () const noexcept
 Gets the preferred popup menu direction.
 
int getInitiallySelectedItemId () const noexcept
 Gets the ID of the item that must be selected when the menu is initially shown.
 

Detailed Description

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.

...
menu.showMenu (PopupMenu::Options().withMinimumWidth (100)
Class used to create a set of options to pass to the show() method.
Options withMaximumNumColumns(int maxNumColumns) const
Sets the maximum number of columns in the popup window.
Options withMinimumWidth(int minWidth) const
Sets the minimum width of the popup window.
Options withTargetComponent(Component *targetComponent) const
Sets the target component to use when displaying the menu.
Creates and displays a popup-menu.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88

Definition at line 460 of file juce_PopupMenu.h.

Member Enumeration Documentation

◆ PopupDirection

enum class juce::PopupMenu::Options::PopupDirection
strong

Definition at line 469 of file juce_PopupMenu.h.

Constructor & Destructor Documentation

◆ Options()

juce::PopupMenu::Options::Options ( )

By default, the target screen area will be the current mouse position.

Definition at line 1968 of file juce_PopupMenu.cpp.

Member Function Documentation

◆ forSubmenu()

PopupMenu::Options juce::PopupMenu::Options::forSubmenu ( ) const

Returns a copy of these options with the target component set to null.

The value of the top-level target component will not be changed.

See also
getTargetComponent(), getTopLevelTargetComponent()

Definition at line 2052 of file juce_PopupMenu.cpp.

◆ getInitiallySelectedItemId()

int juce::PopupMenu::Options::getInitiallySelectedItemId ( ) const
noexcept

Gets the ID of the item that must be selected when the menu is initially shown.

See also
withItemThatMustBeVisible

Definition at line 649 of file juce_PopupMenu.h.

◆ getItemThatMustBeVisible()

int juce::PopupMenu::Options::getItemThatMustBeVisible ( ) const
noexcept

Gets the ID of the item that must be visible when the menu is initially shown.

See also
withItemThatMustBeVisible

Definition at line 637 of file juce_PopupMenu.h.

◆ getMaximumNumColumns()

int juce::PopupMenu::Options::getMaximumNumColumns ( ) const
noexcept

Gets the maximum number of columns.

See also
withMaximumNumColumns

Definition at line 619 of file juce_PopupMenu.h.

◆ getMinimumNumColumns()

int juce::PopupMenu::Options::getMinimumNumColumns ( ) const
noexcept

Gets the minimum number of columns.

See also
withMinimumNumColumns

Definition at line 625 of file juce_PopupMenu.h.

◆ getMinimumWidth()

int juce::PopupMenu::Options::getMinimumWidth ( ) const
noexcept

Gets the minimum width.

See also
withMinimumWidth

Definition at line 613 of file juce_PopupMenu.h.

◆ getParentComponent()

Component * juce::PopupMenu::Options::getParentComponent ( ) const
noexcept

Gets the parent component.

This may be nullptr if the Component has been deleted.

See also
withParentComponent

Definition at line 581 of file juce_PopupMenu.h.

◆ getPreferredPopupDirection()

PopupDirection juce::PopupMenu::Options::getPreferredPopupDirection ( ) const
noexcept

Gets the preferred popup menu direction.

See also
withPreferredPopupDirection

Definition at line 643 of file juce_PopupMenu.h.

◆ getStandardItemHeight()

int juce::PopupMenu::Options::getStandardItemHeight ( ) const
noexcept

Gets the default height of items in the menu.

See also
withStandardItemHeight

Definition at line 631 of file juce_PopupMenu.h.

◆ getTargetComponent()

Component * juce::PopupMenu::Options::getTargetComponent ( ) const
noexcept

Gets the target component.

This may be nullptr if the Component has been deleted.

See also
withTargetComponent

Definition at line 587 of file juce_PopupMenu.h.

◆ getTargetScreenArea()

Rectangle< int > juce::PopupMenu::Options::getTargetScreenArea ( ) const
noexcept

Gets the target screen area.

See also
withTargetScreenArea

Definition at line 607 of file juce_PopupMenu.h.

◆ getTopLevelTargetComponent()

Component * juce::PopupMenu::Options::getTopLevelTargetComponent ( ) const
noexcept

Gets the target component that was set for the top-level menu.

When querying the options of a submenu, getTargetComponent() will always return nullptr, while getTopLevelTargetComponent() will return the target passed to withTargetComponent() when creating the top-level menu.

Definition at line 595 of file juce_PopupMenu.h.

◆ hasWatchedComponentBeenDeleted()

bool juce::PopupMenu::Options::hasWatchedComponentBeenDeleted ( ) const
noexcept

Returns true if the menu was watching a component, and that component has been deleted, and false otherwise.

See also
withDeletionCheck

Definition at line 601 of file juce_PopupMenu.h.

◆ withDeletionCheck()

PopupMenu::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.

Definition at line 2005 of file juce_PopupMenu.cpp.

◆ withInitiallySelectedItem()

PopupMenu::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.

Definition at line 2047 of file juce_PopupMenu.cpp.

◆ withItemThatMustBeVisible()

PopupMenu::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.

Definition at line 2032 of file juce_PopupMenu.cpp.

◆ withMaximumNumColumns()

PopupMenu::Options juce::PopupMenu::Options::withMaximumNumColumns ( int  maxNumColumns) const

Sets the maximum number of columns in the popup window.

Definition at line 2022 of file juce_PopupMenu.cpp.

◆ withMinimumNumColumns()

PopupMenu::Options juce::PopupMenu::Options::withMinimumNumColumns ( int  minNumColumns) const

Sets the minimum number of columns in the popup window.

Definition at line 2017 of file juce_PopupMenu.cpp.

◆ withMinimumWidth()

PopupMenu::Options juce::PopupMenu::Options::withMinimumWidth ( int  minWidth) const

Sets the minimum width of the popup window.

Definition at line 2012 of file juce_PopupMenu.cpp.

◆ withMousePosition()

PopupMenu::Options juce::PopupMenu::Options::withMousePosition ( ) const

Sets the target screen area to match the current mouse position.

Make sure to call this after withTargetComponent().

See also
withTargetScreenArea

Definition at line 2000 of file juce_PopupMenu.cpp.

◆ withParentComponent()

PopupMenu::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.

Definition at line 2037 of file juce_PopupMenu.cpp.

◆ withPreferredPopupDirection()

PopupMenu::Options juce::PopupMenu::Options::withPreferredPopupDirection ( PopupDirection  direction) const

Sets the direction of the popup menu relative to the target screen area.

Definition at line 2042 of file juce_PopupMenu.cpp.

◆ withStandardItemHeight()

PopupMenu::Options juce::PopupMenu::Options::withStandardItemHeight ( int  standardHeight) const

Sets the default height of each item in the popup menu.

Definition at line 2027 of file juce_PopupMenu.cpp.

◆ withTargetComponent() [1/2]

PopupMenu::Options juce::PopupMenu::Options::withTargetComponent ( Component targetComponent) const

Definition at line 1990 of file juce_PopupMenu.cpp.

◆ withTargetComponent() [2/2]

PopupMenu::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.

See also
withTargetComponent, withTargetScreenArea

Definition at line 1980 of file juce_PopupMenu.cpp.

◆ withTargetScreenArea()

PopupMenu::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:

static Point< int > getMousePosition()
Returns the mouse position.
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle withPosition(ValueType newX, ValueType newY) const noexcept
Returns a rectangle with the same size as this one, but a new position.

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().

See also
withMousePosition

Definition at line 1995 of file juce_PopupMenu.cpp.


The documentation for this class was generated from the following files: