Skip to content

Latest commit

 

History

History
85 lines (69 loc) · 5.11 KB

commands.md

File metadata and controls

85 lines (69 loc) · 5.11 KB
title page_title description slug tags position
Commands
Commands
This article lists and explains the commands exposed by the RadSyntaxEditor control.
radsyntaxeditor-commands
commands,radsyntaxeditor
5

Commands

RadSyntaxEditor exposes its functionality through various commands that can be executed on its behalf. All commands can be accessed through the Commands property of the control. Here's a full list of the available commands:

  • OpenFindDialogCommand—Opens the find dialog. If there is any selected text, it is loaded in the search textbox.
  • CloseFindDialogCommand—Closes the find dialog.
  • NavigateNextMatchCommand—Navigates to the next matched text in the editor and selects it. If the match is contained in a folded region, it is unfolded. Takes as a parameter the search text.
  • NavigatePreviousMatchCommand—Navigates to the previous matched text in the editor and selects it. If the match is contained in a folded region, it is unfolded. Takes as a parameter the search text.
  • HighlightAllMatchesCommand—Tries to highlight all span matches via all registered TextSearchHighlightTaggers. Takes as a parameter the search text.
  • CodeCompletionCommand—Shows the IntelliSense code completion dialog.
  • CutCommand—Cuts the selected text or the current line if there is no selection.
  • CopyCommand—Copies the selected text or the current line if there is no selection.
  • PasteCommand—Pastes over the selected text or at the caret's position if there is no selection.
  • BackspaceCommand—Deletes the selected text or the last character before the caret if there is no selection.
  • DeleteCommand—Deletes the selected text or the first character after the caret if there is no selection.
  • DeleteFullLineCommand—Deletes the full line on which the cursor currently is.
  • DeleteWordToLeftCommand—Deletes the word to the left of the cursor.
  • DeleteWordToRightCommand—Deletes the word to the right of the cursor.
  • IndentCommand—Indents the selected text or the current line if there is no selection.
  • UnindentCommand—Unindents the selected text or the current line if there is no selection.
  • MoveCaretCommand—Moves the caret depending on the CaretMovementType parameter which is passed.
  • RedoCommand—Redoes the last undo action.
  • UndoCommand—Undoes the last action.
  • SelectAllCommand—Selects all the text.
  • ToggleInsertModeCommand—Toggles the insert mode.

The following example demonstrates how to select and delete the first occurrence of the "Telerik" word from the loaded text in code-behind and in XAML:

[C#] Use commands in code-behind

{{region radsyntaxeditor-commands-1}} this.syntaxEditor.Commands.NavigateNextMatchCommand.Execute("Telerik"); this.syntaxEditor.Commands.DeleteCommand.Execute(null); {{endregion}}

[XAML] Use commands in XAML

{{region radsyntaxeditor-commands-2}} <telerik:RadSyntaxEditor x:Name="syntaxEditor" /> <telerik:RadButton Content="Select Next Match" Command="{Binding Commands.NavigateNextMatchCommand, ElementName=syntaxEditor}" CommandParameter="Telerik" /> <telerik:RadButton Content="Delete" Command="{Binding Commands.DeleteCommand, ElementName=syntaxEditor}" /> {{endregion}}

Managing Commands

RadSyntaxEditor allows you to register and unregister its commands. To do so, you can utilize the RegisterCommand and UnregisterCommand methods of the KeyBindings property of the RadSyntaxEditor control.

The following examples show how to register and unregister the CodeCompletionCommand:

[C#] Register a command

{{region radsyntaxeditor-commands-3}} SyntaxEditorDelegateCommand codeCompletionCommand = (SyntaxEditorDelegateCommand)this.syntaxEditor.Commands.CodeCompletionCommand; this.syntaxEditor.KeyBindings.RegisterCommand(codeCompletionCommand, Key.Enter, ModifierKeys.Control); {{endregion}}

[VB.NET] Register a command

{{region radsyntaxeditor-commands-4}} Dim codeCompletionCommand As SyntaxEditorDelegateCommand = CType(Me.syntaxEditor.Commands.CodeCompletionCommand, SyntaxEditorDelegateCommand) Me.syntaxEditor.KeyBindings.RegisterCommand(codeCompletionCommand, Key.Enter, ModifierKeys.Control) {{endregion}}

[C#] Unregister a command

{{region radsyntaxeditor-commands-5}} SyntaxEditorDelegateCommand codeCompletionCommand = (SyntaxEditorDelegateCommand)this.syntaxEditor.Commands.CodeCompletionCommand; this.syntaxEditor.KeyBindings.UnregisterCommand(codeCompletionCommand); {{endregion}}

[VB.NET] Unregister a command

{{region radsyntaxeditor-commands-6}} Dim codeCompletionCommand As SyntaxEditorDelegateCommand = CType(Me.syntaxEditor.Commands.CodeCompletionCommand, SyntaxEditorDelegateCommand) Me.syntaxEditor.KeyBindings.UnregisterCommand(codeCompletionCommand) {{endregion}}

important Registering and unregistering commands would require the RadSyntaxEditor control to be loaded. You can utilize the RegisterCommand and UnregisterCommand methods in the Loaded event of the control.

See Also

  • [Events]({%slug radsyntaxeditor-events%})