PopupMenu#

Qualified name: delphivcl.PopupMenu

class PopupMenu#

Bases: Menu

TPopupMenu encapsulates the properties, methods, and events of a pop-up menu. Use TPopupMenu to define the pop-up menu that appears when the user clicks on a control with the right mouse button. To make a pop-up menu available, assign the TPopupMenu object to the control’s PopupMenu property.

Tip: To create a popup menu that users can configure at runtime, use the TStandardMenuPopup component with an action manager instead. Note: If the popup menu’s ParentBiDiMode is true, the popup menu’s BiDiMode is set to the BiDiMode of the control that activates it. If a control cannot be found, the BiDiMode is set to the value of the Application object’s BiDiMode. The popup menu’s BiDiMode affects all of its menu items.

Methods

BindMethodsToEvents

Connects methods to component events if they are named using the following pattern: Prefix_ComponentName_EventName.

CloseMenu

Closes the pop-up menu onscreen.

Create

Creates an instance of TPopupMenu.

Destroy

Destroys an instance of TPopupMenu.

GetParentComponent

Returns the parent of a component.

HasParent

Indicates whether the component has a parent to handle its filing.

Popup

Displays the pop-up menu onscreen.

Attributes

Alignment

Determines where the pop-up menu appears when the user clicks the right mouse button.

AutoHotkeys

Determines whether the accelerator keys for menu items can be reset automatically.

AutoLineReduction

Determines whether redundant separator bars are automatically removed from the menu.

AutoPopup

Determines whether the pop-up menu appears automatically when the user clicks the right mouse button.

BiDiMode

Determines the layout of the menu in Middle East locales.

ClassName

Returns the TObject.ClassName

ComObject

Specifies the interface reference implemented by the component.

ComponentCount

Returns the owned component count

ComponentIndex

Indicates the position of the component in its owner's Components property array.

ComponentState

Describes the current state of the component, indicating when a component needs to avoid certain actions.

ComponentStyle

Governs the behavior of the component.

Components

Returns an iterator over the owned components

DesignInfo

Contains information used by the Form designer.

Handle

Provides access to the Windows menu handle for the menu.

HelpContext

Specifies a context ID for the entire pop-up menu.

Images

Lists the images that can appear beside individual menu items.

Items

Describes the elements of the menu.

MenuAnimation

Specifies how the menu appears when it is first displayed.

Name

Specifies the name of the component as referenced in code.

Observers

Indicates the TObservers object added to the TComponent.

OnChange

<Delphi property OnChange of type TPopupMenu at 21141464000>

OnClose

<Delphi property OnClose of type TPopupMenu at 211414640D0>

OnPopup

<Delphi property OnPopup of type TPopupMenu at 211414641A0>

Owner

Returns the Component Owner

OwnerDraw

Specifies whether the menu items are drawn by the application.

ParentBiDiMode

Indicates whether the BiDiMode property is inherited from the control that uses the menu.

PopupComponent

Indicates the component that last displayed the popup menu in response to a right mouse click.

PopupPoint

Indicates the location where the pop-up menu appears.

Tag

Stores a NativeInt integral value as a part of a component.

TrackButton

Specifies which mouse button activates the popup menu when it is associated with a toolbar button.

VCLComObject

Represents information used internally by components that support COM.

WindowHandle

Provides access to the handle of the window that uses the menu.

Alignment#

Determines where the pop-up menu appears when the user clicks the right mouse button. Set Alignment to control the placement of the popup menu. Alignment controls whether the menu appears to the left of the mouse, to the right of the mouse, or centered over the mouse. By default, the menu appears with its top left corner under the mouse (paLeft).

AutoHotkeys#

Determines whether the accelerator keys for menu items can be reset automatically. Set AutoHotkeys to indicate whether the menu should automatically ensure that accelerator keys for its items are reset if necessary so that every menu item has an accelerator key and no two items have the same accelerator key. This ensures that menu items added dynamically at runtime can have accelerator keys that do not introduce conflicts. TMenu tries to preserve all existing accelerator key mappings when adjusting the accelerator keys, but may be forced to change some in order to ensure that every item has a unique accelerator. Before the menu is displayed, the menu checks and adjusts the accelerator key mappings if AutoHotkeys is maAutomatic. When AutoHotkeys is maManual, the menu does not alter the top-level menu items, but may adjust the accelerator keys for submenus, depending on the AutoHotkeys property of the menu item that is the parent of the submenu. When AutoHotkeys is maManual, an application can still adjust the menu items by calling the Items property’s RethinkHotkeys method. AutoHotkeys merely controls whether this adjustment occurs automatically.

Note: The AutoHotkeys property of a menu is linked to the AutoHotkeys property of the TMenuItems object that implements its Items property. Setting one sets the other.

AutoLineReduction#

Determines whether redundant separator bars are automatically removed from the menu. Set AutoLineReduction to indicate whether the menu should automatically ensure that the menu does not start or end with a separator bar and that two separator bars do not appear next to each other. This ensures that menus built dynamically at runtime do not have separator bars in undesired positions. Before the menu is displayed, it removes superfluous separator bars when AutoLineReduction is maAutomatic. When AutoLineReduction is maManual, the menu does not remove separators from the top-level menu items, but may remove superfluous separators from submenus, depending on the AutoLineReduction property of the menu item that is the parent of the submenu. When AutoLineReduction is maManual, an application can still remove superfluous separators by calling the Items property’s RethinkLines method. AutoLineReduction merely determines whether this adjustment occurs automatically.

Note: The AutoLineReduction property of a menu is linked to the AutoLineReduction property of the TMenuItems object that implements its Items property. Setting one sets the other.

AutoPopup#

Determines whether the pop-up menu appears automatically when the user clicks the right mouse button. Set AutoPopup to true to cause the pop-up menu to appear automatically when the user clicks the right mouse button on a control that has the pop-up menu specified as its PopupMenu property. The application key present on keyboards specifically designed for 32-bit Windows will also show this menu when pressed. Set AutoPopup to false if the appearance of the pop-up menu should be controlled programmatically. To display a pop-up menu when AutoPopup is false, use the Popup method.

BiDiMode#

Determines the layout of the menu in Middle East locales. Set BiDiMode to control the layout of menu items. BiDiMode controls whether the menu items read from left to right or right to left.

BindMethodsToEvents(prefix)#

Connects methods to component events if they are named using the following pattern: Prefix_ComponentName_EventName. Example: def handle_button1_OnClick(Sender): pass The function returns a list of tuples. Each tuple contains the name of the component, the name of the event and the method object assigned to the event. Note that the prefix parameter is optional and will default to “handle_”.

CloseMenu()#

Closes the pop-up menu onscreen. Call CloseMenu to close the pop-up menu.

ComponentCount#

Returns the owned component count

Components#

Returns an iterator over the owned components

Create(AOwner: Component)#

Creates an instance of TPopupMenu. Call Create to create to create a pop-up menu at runtime. Pop-up menus placed in forms or data modules at design time are created automatically.

Destroy()#

Destroys an instance of TPopupMenu. Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TPopupMenu reference is not nil, and only then calls Destroy.

GetParentComponent()#

Returns the parent of a component.

HasParent()#

Indicates whether the component has a parent to handle its filing.

HelpContext#

Specifies a context ID for the entire pop-up menu. Use HelpContext to associate a help screen with the entire pop-up menu. Each screen in the Help system should have a unique context ID. When a component is selected in the application, pressing F1 displays the Help screen associated with the value of HelpContext. To associate a help screen with the individual items in the pop-up menu, use the HelpContext property of the associated TMenuItem objects.

Images#

Lists the images that can appear beside individual menu items. Use Images to hold the set of images that can appear beside menu items in the menu. Individual menu items set their ImageIndex property to indicate which image in the list appears to the left of the menu item caption. Images in the list should be 16x16.

Tip: If the application uses action lists, this property should be the value of the action list’s Images property. This way, menu items and buttons that do the same thing can display the same image.

MenuAnimation#

Specifies how the menu appears when it is first displayed. Use MenuAnimation to specify how the popup menu appears on the screen. The menu can simply appear as a whole, or can slide into view like a window shade being drawn from any edge.

Note: MenuAnimation only has an effect when running on Windows 98, NT 5.0, or later.

OnChange#

<Delphi property OnChange of type TPopupMenu at 21141464000>

OnClose#

<Delphi property OnClose of type TPopupMenu at 211414640D0>

OnPopup#

<Delphi property OnPopup of type TPopupMenu at 211414641A0>

Owner#

Returns the Component Owner

OwnerDraw#

Specifies whether the menu items are drawn by the application. Set OwnerDraw to true to indicate that the application will draw menu items in an OnDrawItem event handler. When OwnerDraw is true, menu items receive an OnMeasureItem and an OnDrawItem event when they need to be rendered on screen. Set OwnerDraw to false to accept the default drawing. When OwnerDraw is false, menu items display the caption with an optional image to the left (If the Images and ImageIndex properties are set). Owner-draw menus are useful for displaying the value that appears when selecting a menu item. For example, in a menu that allows users to choose a color, an owner-draw menu could display rectangles drawn in the designated color, rather than color names.

ParentBiDiMode#

Indicates whether the BiDiMode property is inherited from the control that uses the menu. By default, ParentBiDiMode is true, indicating that the layout of menu items follows the BiDiMode setting of the associated form or control. Change ParentBiDiMode to false to override the default BiDiMode setting and control the menu’s layout independently.

Popup(X: Integer, Y: Integer)#

Displays the pop-up menu onscreen. Call Popup to bring up the pop-up menu. The menu appears at the screen coordinates indicated by the values (in pixels) of X and Y.

PopupComponent#

Indicates the component that last displayed the popup menu in response to a right mouse click. Read PopupComponent to determine which control is currently using the popup menu. In applications where multiple controls share the same pop-up menu, use PopupComponent to determine which of them displayed the menu. Set PopupComponent to associate a control with the menu before calling the Popup method programmatically to bring up the pop-up menu.

PopupPoint#

Indicates the location where the pop-up menu appears. This public property is used internally to locate the popup menu. Its value is set by the Popup method.

TrackButton#

Specifies which mouse button activates the popup menu when it is associated with a toolbar button. Use TrackButton to specify which mouse button activates the popup menu when it is associated with a toolbar button.