Skip to main content

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 if 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 CommandId | RibbonItemId | ContextMenuItem

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 CommandId | RibbonItemId | ContextMenuItem

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 if 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 if the specified item is not found.

Remarks

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