Back to Devexpress

IContextMenu Interface

aspnetcore-js-devexpress-dot-richedit-6f99537c.md

latest8.2 KB
Original Source

IContextMenu Interface

Declares context menu settings and methods.

Declaration

ts
export interface IContextMenu

Properties

enabled Property

Specifies whether the context menu is enabled.

Declaration

ts
enabled: boolean

Property Value

TypeDescription
boolean

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

|

Remarks

javascript
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

ts
items: ContextMenuItem[]

Property Value

TypeDescription
ContextMenuItem[]

An array of items.

|

Remarks

javascript
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

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

Parameters

NameTypeDescription
idCommandIdRibbonItemId

An item identifier.

|

Returns

TypeDescription
ContextMenuItem

An item with the specified id property value. null if an item with the specified identifier is not found.

|

Remarks

javascript
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

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

Parameters

NameTypeDescription
itemContextMenuItem

A context menu item to insert.

| | index | number |

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

|

Returns

TypeDescription
ContextMenuItem

The item that was inserted.

|

Remarks

javascript
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

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

Parameters

NameTypeDescription
itemContextMenuItem

A context menu item to insert.

| | target | ContextMenuItem | CommandId | RibbonItemId |

The target item or its identifier.

|

Returns

TypeDescription
ContextMenuItem

The item that was inserted.

|

Remarks

javascript
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

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

Parameters

NameTypeDescription
itemContextMenuItem

A context menu item to insert.

| | target | ContextMenuItem | CommandId | RibbonItemId |

The target item or its identifier.

|

Returns

TypeDescription
ContextMenuItem

The item that was inserted.

|

Remarks

javascript
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

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

Parameters

NameTypeDescription
idCommandIdRibbonItemId

An item identifier.

|

Returns

TypeDescription
ContextMenuItem

The item that was removed. null if the item with the specified id property value is not found.

|

Remarks

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

Run Demo: Context Menu Customization

removeItem(item) Method

Removes an item from the context menu.

Declaration

ts
removeItem(
    item: ContextMenuItem
): ContextMenuItem | null

Parameters

NameTypeDescription
itemContextMenuItem

A context menu item to remove.

|

Returns

TypeDescription
ContextMenuItem

The item that was removed. null if the specified item is not found.

|

Remarks

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