I'm using ej diagram of syncfusion in asp.net mvc program and I want to know is there any option to let me create a new node by hitting enter or any other key? I mean any keyboard keys that I can use for creating and editing diagram or any keyboard event handler that I implement this feature by myself?
Asked
Active
Viewed 96 times
1 Answers
1
To achieve your requirement, please use “Command Manager” which provides support to map/bind command execution with desired combination of key gestures. Please refer the code snippet below which represents the creation of the node, when we press the Shift+C key.
Code snippet:
DiagramProperties model = new DiagramProperties();
Dictionary<string, object> Commands = new Dictionary<string, object>()
{
{
//command name
"createNode",
//command definition
new Command()
{
//Name of the method/command handler that is defined in scripts
Execute = "execute",
//Gesture to define when the command is to be executed
Gesture = new Gesture()
{
//Combination of keys and modifier keys
Key = Keys.C, KeyModifiers = KeyModifiers.Shift
}
}
}
};
model.CommandManager.Commands = Commands;
<script type="text/javascript">
function execute(args) {
//add the node
$("#Diagram1").ejDiagram("instance").add({ name: "rect", width: 100, height: 100, offsetX: 200, offsetY: 200 })
}
</script>