Back to Devexpress

TcxPopupMenuLayout.MenuItems Property

vcl-cximage-dot-tcxpopupmenulayout.md

latest4.0 KB
Original Source

TcxPopupMenuLayout.MenuItems Property

Specifies visible items in the image editor context menu.

Declaration

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

Property Value

TypeDescription
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…

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:

delphi
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;
cpp
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";

Add Custom Item Functionality

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

delphi
procedure TMyForm.cxImage1PropertiesCustomClick(Sender: TObject)
begin
  ShowMessage('My message');
end;
cpp
void __fastcall TMyForm::cxImage1PropertiesCustomClick(TObject *Sender)
{
  ShowMessage("My message");
}

Default Value

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

See Also

TcxPopupMenuLayout.CustomMenuItemCaption Property

TcxPopupMenuLayout.CustomMenuItemGlyph Property

TcxPopupMenuLayout Class

TcxPopupMenuLayout Members

cxImage Unit