vcl-cximage-dot-tcxpopupmenulayout.md
Specifies visible items in the image editor context menu.
property MenuItems: TcxPopupMenuItems read; write; default [pmiCut, pmiCopy, pmiPaste, pmiDelete, pmiLoad, pmiWebCam, pmiSave, pmiEdit];
| Type | Description |
|---|---|
| TcxPopupMenuItems |
The current set of pop-up menu items.
|
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…
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.
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.
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;
TcxPopupMenuLayout *AMenuLayout;
// ...
AMenuLayout = cxImage1->Properties->PopupMenuLayout;
// Redefines all available menu items
AMenuLayout->MenuItems = TcxPopupMenuItems() << pmiCut << pmiCopy << pmiPaste << pmiDelete << pmiLoad << pmiSave << pmiEdit << pmiCustom;
AMenuLayout->CustomMenuItemCaption = "Custom Menu Item";
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;
void __fastcall TMyForm::cxImage1PropertiesCustomClick(TObject *Sender)
{
ShowMessage("My message");
}
The MenuItems property’s default value is [pmiCut, pmiCopy, pmiPaste, pmiDelete, pmiLoad, pmiWebCam, pmiSave, pmiEdit].
See Also
TcxPopupMenuLayout.CustomMenuItemCaption Property