Skip to main content

TcxPopupMenuLayout.MenuItems Property

Specifies visible items in the image editor context menu.

Declaration

property MenuItems: TcxPopupMenuItems read; write; default [pmiCut, pmiCopy, pmiPaste, pmiDelete, pmiLoad, pmiWebCam, pmiSave, pmiEdit];

Property Value

Type Description
TcxPopupMenuItems

The current set of pop-up menu items.

Remarks

Use the MenuItems property to hide or display individual menu items. The image editor context menu initially displays the following items: Cut, Copy, Paste, Delete, Load…, Assign From Camera…, Save As…, and Edit…

VCL Editors Library: The Default Context Menu

Note

The Assign From Camera… item that invokes the Camera Preview dialog is enabled only if at least one camera is available to the camera manager.

Add and Configure a Custom Item

To create a custom item in the image editor context menu, add the pmiCustom flag to the MenuItems property value. The new item is displayed at the bottom of the context menu. A separator line delimits the custom item from built-in items.

You can use CustomMenuItemCaption and CustomMenuItemGlyph properties to define caption and glyph for the new item.

Code Example: Context Menu Customization

The following code example removes the predefined Assign From Camera… item and adds a custom menu item:

var
  AMenuLayout: TcxPopupMenuLayout;
begin
  AMenuLayout := cxImage1.Properties.PopupMenuLayout;
  AMenuLayout.MenuItems := AMenuLayout.MenuItems - [pmiWebCam]; // Removes the "Assign from Camera..." item
  AMenuLayout.MenuItems := AMenuLayout.MenuItems + [pmiCustom]; // Adds a custom menu item at the bottom
  AMenuLayout.CustomMenuItemCaption := 'Custom Menu Item';
end;

VCL Editors Library: A Custom Context Menu Example

Add Custom Item Functionality

To respond to a click on the configured custom menu item, handle the target image editor’s Properties.OnCustomClick event:

procedure TMyForm.cxImage1PropertiesCustomClick(Sender: TObject)
begin
  ShowMessage('My message');
end;

Default Value

The MenuItems property’s default value is [pmiCut, pmiCopy, pmiPaste, pmiDelete, pmiLoad, pmiWebCam, pmiSave, pmiEdit].

See Also