Class SlashMenuSelectEventArgs
Represents the arguments provided for the SlashMenuItemSelecting event, containing information about the item selection process and control over its cancellation.
Inheritance
Namespace: Syncfusion.Blazor.RichTextEditor
Assembly: Syncfusion.Blazor.dll
Syntax
public class SlashMenuSelectEventArgs : Object
Remarks
The SlashMenuSelectEventArgs class provides the necessary data and control to handle item selection events effectively. It exposes properties that allow you to examine the item being selected and decide if the selection should be canceled.
Examples
This example demonstrates how to handle the SlashMenuItemSelecting event using SlashMenuSelectEventArgs.
<SfRichTextEditor SlashMenuItemSelecting="OnSlashMenuItemSelecting">
<RichTextEditorSlashMenuSettings Enable="true" Items="Tools" />
</SfRichTextEditor>
@code {
private List<SlashMenuItemModel> Tools = new List<SlashMenuItemModel>
{
new SlashMenuItemModel { Text = "Heading 1", Command = SlashMenuCommand.Heading1, Description = "Formats text as a level 1 heading" }
};
private void OnSlashMenuItemSelecting(SlashMenuSelectEventArgs<SlashMenuItemModel> args)
{
if (args.ItemData.Command == SlashMenuCommand.Heading1)
{
args.Cancel = true; // Cancel selection for Heading1
}
}
}
Constructors
SlashMenuSelectEventArgs()
Declaration
public SlashMenuSelectEventArgs()
Properties
Cancel
Gets or sets whether the item selection action should be canceled or not.
Declaration
public bool Cancel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Setting this property to true
prevents the selected item's command from executing.
The default value is false
, allowing the selection to proceed.
Examples
This example shows how to cancel item selection using the Cancel property in a SlashMenuItemSelecting event handler.
<SfRichTextEditor SlashMenuItemSelecting="OnSlashMenuItemSelecting">
<RichTextEditorSlashMenuSettings Enable="true" Items="Tools" />
</SfRichTextEditor>
@code {
private List<SlashMenuItemModel> Tools = new List<SlashMenuItemModel>
{
new SlashMenuItemModel { Text = "Heading 1", Command = SlashMenuCommand.Heading1 }
};
private void OnSlashMenuItemSelecting(SlashMenuSelectEventArgs<SlashMenuItemModel> args)
{
args.Cancel = true; // Cancel the selection
}
}
ItemData
Gets or sets the selected slash menu item data from the data source.
Declaration
public SlashMenuItemModel ItemData { get; set; }
Property Value
Type | Description |
---|---|
SlashMenuItemModel | An item data. |
Remarks
This property provides access to the SlashMenuItemModel instance being selected in the slash menu.
If null
, no valid item is selected, and the event may be ignored.
Examples
This example shows how to access the ItemData property in a SlashMenuItemSelecting event handler.
<SfRichTextEditor SlashMenuItemSelecting="OnSlashMenuItemSelecting">
<RichTextEditorSlashMenuSettings Enable="true" Items="Tools" />
</SfRichTextEditor>
@code {
private List<SlashMenuItemModel> Tools = new List<SlashMenuItemModel>
{
new SlashMenuItemModel { Text = "Heading 1", Command = SlashMenuCommand.Heading1 }
};
private void OnSlashMenuItemSelecting(SlashMenuSelectEventArgs<SlashMenuItemModel> args)
{
var selectedText = args.ItemData?.Text; // Access selected item's text
}
}