Class KeyGesture
Represents a keyboard combination that can be used to invoke a command.
Inheritance
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class KeyGesture : Object
Remarks
The KeyGesture class provides a way to define and use keyboard shortcuts within applications. It associates a specific keyboard combination with a command that gets executed when the gesture is recognized.
Examples
<SfDiagramComponent >
@* Initializing the custom commands*@
<CommandManager Commands = "@command">
</CommandManager>
</SfDiagramComponent>
@code
{
DiagramObjectCollection<KeyboardCommand> command = new DiagramObjectCollection<KeyboardCommand>()
{
new Command()
{
Name = "CustomGroup",
Gesture = new KeyGesture() { Key = DiagramKeys.G, Modifiers = ModifierKeys.Control }
},
new Command()
{
Name = "CustomUngroup",
Gesture = new KeyGesture() { Key = DiagramKeys.U, Modifiers = ModifierKeys.Control }
},
};
}
Constructors
KeyGesture()
Declaration
public KeyGesture()
Properties
Key
Gets or sets the key associated with this KeyGesture.
Declaration
public DiagramKeys Key { get; set; }
Property Value
Type | Description |
---|---|
DiagramKeys | A DiagramKeys representing the key for the gesture. The default value is None. |
Remarks
This property is utilized to define custom keyboard commands within a diagram component. The assigned key works in conjunction with ModifierKeys to trigger specific commands.
Examples
The following example demonstrates the creation and usage of custom keyboard commands in a SfDiagramComponent.
<SfDiagramComponent>
@* Initializing the custom commands *@
<CommandManager Commands="@command">
</CommandManager>
</SfDiagramComponent>
@code {
DiagramObjectCollection<KeyboardCommand> command = new DiagramObjectCollection<KeyboardCommand>()
{
new Command()
{
Name = "CustomGroup",
Gesture = new KeyGesture() { Key = DiagramKeys.G, Modifiers = ModifierKeys.Control }
},
new Command()
{
Name = "CustomUngroup",
Gesture = new KeyGesture() { Key = DiagramKeys.U, Modifiers = ModifierKeys.Control }
},
};
}
Modifiers
Gets or sets the modifier keys associated with this KeyGesture.
Declaration
public ModifierKeys Modifiers { get; set; }
Property Value
Type | Description |
---|---|
ModifierKeys | A ModifierKeys representing the modifier keys for the gesture. The default value is None. |
Remarks
This property is used to define modifier keys for custom keyboard commands within a diagram component. These keys work alongside Key to trigger specific commands.
Examples
The following example demonstrates the creation and usage of custom keyboard commands in a SfDiagramComponent.
<SfDiagramComponent>
@* Initializing the custom commands *@
<CommandManager Commands="@command">
</CommandManager>
</SfDiagramComponent>
@code {
DiagramObjectCollection<KeyboardCommand> command = new DiagramObjectCollection<KeyboardCommand>()
{
new Command()
{
Name = "CustomGroup",
Gesture = new KeyGesture() { Key = DiagramKeys.G, Modifiers = ModifierKeys.Control }
},
new Command()
{
Name = "CustomUngroup",
Gesture = new KeyGesture() { Key = DiagramKeys.U, Modifiers = ModifierKeys.Control }
},
};
}