Back to Devexpress

RichEditControl.AssignShortcutKeyToCommand(Keys, Keys, RichEditCommandId, Boolean) Method

wpf-devexpress-dot-xpf-dot-richedit-dot-richeditcontrol-dot-assignshortcutkeytocommand-x28-keys-keys-richeditcommandid-boolean-x29.md

latest3.9 KB
Original Source

RichEditControl.AssignShortcutKeyToCommand(Keys, Keys, RichEditCommandId, Boolean) Method

Assigns a shortcut key to a command. Shortcut key is available for all RichEdit views.

Namespace : DevExpress.Xpf.RichEdit

Assembly : DevExpress.Xpf.RichEdit.v25.2.dll

NuGet Package : DevExpress.Wpf.RichEdit

Declaration

csharp
public void AssignShortcutKeyToCommand(
    Keys key,
    Keys modifier,
    RichEditCommandId commandId,
    bool updateToolTip
)
vb
Public Sub AssignShortcutKeyToCommand(
    key As Keys,
    modifier As Keys,
    commandId As RichEditCommandId,
    updateToolTip As Boolean
)

Parameters

NameTypeDescription
keyKeys

A Keys enumeration member specifying a key to assign.

| | modifier | Keys |

A Keys enumeration member specifying a modifier key.

| | commandId | RichEditCommandId |

A RichEditCommandId enumeration member specifying a command.

| | updateToolTip | Boolean |

true to modify a tooltip of the BarItem to which a command is assigned; otherwise, false.

|

Remarks

The AssignShortcutKeyToCommand method override enables you to modify a tooltip of the bar item (the BarItem.SuperTip property) in the RichEdit UI so that it displays the correct shortcut information. To do this, set the updateToolTip parameter to true.

Note that the RichEditControl’s shortcuts should be assigned after the control is initialized (e.g. in the Window.Loaded event handler).

Note

If the command already has a shortcut, the AssignShortcutKeyToCommand method does not change the related tooltip. The tooltip will show the previously assigned shortcut.

The code sample below assigns the Alt+Y shortcut to the CreateFieldCommand, allowing you to insert a field:

csharp
private void ThemedWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
  richEditControl1.AssignShortcutKeyToCommand(Keys.Y, Keys.Alt, RichEditCommandId.CreateField, true);
}
vb
Private Sub ThemedWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
   richEditControl1.AssignShortcutKeyToCommand(Keys.Y, Keys.Alt, RichEditCommandId.CreateField, True)
End Sub

To remove a command shortcut, use the RichEditControl.RemoveShortcutKey method.

See Also

RemoveShortcutKey

RichEditControl Class

RichEditControl Members

DevExpress.Xpf.RichEdit Namespace