All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.

IContextMenu Interface

Declares context menu settings and methods.

Declaration

export interface IContextMenu

Properties

enabled Property

Specifies whether the context menu is enabled.

Declaration

enabled: boolean

Property Value

Type Description
boolean

true, to enable the context menu; otherwise, false.

Remarks

function onContextMenuShowing(s, e) {
    var characterProperties = s.selection.activeSubDocument.getCharacterProperties(s.selection.intervals[0]);
    if (characterProperties.strikeout==true ) {
        e.contextMenu.enabled = false;
    }
};

items Property

Provides access to the context menu item collection.

Declaration

items: ContextMenuItem[]

Property Value

Type Description
ContextMenuItem[]

An array of items.

Remarks

richEdit.contextMenu.removeItem(richEdit.contextMenu.items[10]);

The context menu contains the set of default commands. To customize it, use the following methods:

Methods

getItem(id) Method

Returns a context menu item with the specified identifier.

Declaration

getItem(
    id: CommandId | RibbonItemId
): ContextMenuItem | null

Parameters

Name Type Description
id CommandId | RibbonItemId

An item identifier.

Returns

Type Description
ContextMenuItem

An item with the specified id property value.

null

An item with the specified identifier is not found.

Remarks

richEdit.contextMenu.getItem(DevExpress.RichEdit.ContextMenuCommandId.Copy).text='Copy the text';

Run Demo: Context Menu Customization

insertItem(item) Method

Inserts an item at the specified position.

Declaration

insertItem(
    item: ContextMenuItem,
    index?: number
): ContextMenuItem

Parameters

Name Type Description
item ContextMenuItem

A context menu item to insert.

index number

The zero-based index at which the specified item should be inserted.

Returns

Type Description
ContextMenuItem

The item that was inserted.

Remarks

richEdit.contextMenu.insertItem(
  new DevExpress.RichEdit.ContextMenuItem(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField, 
  { icon: 'clock', text: 'Insert Date Field', beginGroup: true}), 1);

When you do not specify the item position, the control inserts the item at the bottom of the context menu.

Run Demo: Context Menu Customization

insertItemAfter(item, target) Method

Inserts an item after the target item.

Declaration

insertItemAfter(
    item: ContextMenuItem,
    target: ContextMenuItem | CommandId | RibbonItemId
): ContextMenuItem

Parameters

Name Type Description
item ContextMenuItem

A context menu item to insert.

target ContextMenuItem | CommandId | RibbonItemId

The target item or its identifier.

Returns

Type Description
ContextMenuItem

The item that was inserted.

Remarks

richEdit.contextMenu.insertItemAfter(
  new DevExpress.RichEdit.ContextMenuItem(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField, 
  { icon: 'clock', text: 'Insert Date Field', beginGroup: true}), DevExpress.RichEdit.HomeTabCommandId.Copy);

When the context menu does not contain the target item, the control inserts the item at the bottom of the context menu.

insertItemBefore(item, target) Method

Inserts an item before the target item.

Declaration

insertItemBefore(
    item: ContextMenuItem,
    target: ContextMenuItem | CommandId | RibbonItemId
): ContextMenuItem

Parameters

Name Type Description
item ContextMenuItem

A context menu item to insert.

target ContextMenuItem | CommandId | RibbonItemId

The target item or its identifier.

Returns

Type Description
ContextMenuItem

The item that was inserted.

Remarks

richEdit.contextMenu.insertItemBefore(
  new DevExpress.RichEdit.ContextMenuItem(DevExpress.RichEdit.MailMergeTabCommandId.CreateDateField, 
  { icon: 'clock', text: 'Insert Date Field', beginGroup: true}), DevExpress.RichEdit.HomeTabCommandId.Copy);

When the context menu does not contain the target item, the control inserts the item at the bottom of the context menu.

removeItem(id) Method

Removes an item with the specified identifier from the context menu.

Declaration

removeItem(
    id: CommandId | RibbonItemId
): ContextMenuItem | null

Parameters

Name Type Description
id CommandId | RibbonItemId

An item identifier.

Returns

Type Description
ContextMenuItem

The item that was removed.

null

The item with the specified id property value is not found.

Remarks

richEdit.contextMenu.removeItem(DevExpress.RichEdit.HomeTabCommandId.Copy);

Run Demo: Context Menu Customization

removeItem(item) Method

Removes an item from the context menu.

Declaration

removeItem(
    item: ContextMenuItem
): ContextMenuItem | null

Parameters

Name Type Description
item ContextMenuItem

A context menu item to remove.

Returns

Type Description
ContextMenuItem

The item that was removed.

null

The specified item is not found.

Remarks

richEdit.contextMenu.removeItem(richEdit.contextMenu.items[10]);