We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to finish editing label on enter press

Hi,

When I am editing the label of a connector and press enter, I do not want the label to have a new line, but instead finish editing and apply the text entered (without a new line character) to the label.

Is there any way to do this?




Regards,
David

1 Reply

RT Ramya Thirugnanam Syncfusion Team April 3, 2019 06:29 AM UTC

Hi David,  
 
Please use diagram commandManager to achieve your requirement. While editing a label, when we press enter key, the command manager executes method(stopEdit) will be called and we have performed endEdit action in it. Please refer to the code example and help documentation.  
 
Code example:   
Aspx.cs  
Aspx  
var Commands = new Dictionary<string, object>  
          {           
              {  
                "stopEditing",  
                new Command  
                {  
                    CanExecute = "canStopEdit",  
                  Execute = “stopEdit”,  
                    Gesture = new Gesture {Key = Keys.Enter }  
                }  
                },  
          };  
            DiagramContent.CommandManager.Commands = Commands;  
<script>  
function canStopEdit() {  
     if (args.model.selectedItems.children.length > 0) {  
                                        return true;  
         }  
    }  
 function stopEdit() {  
        var diagram = $("#diagram").ejDiagram("instance");  
    //label editing stop once we press an enter key                                             diagram.model.commandManager.commands["endEdit"].execute(args);  
    }  
</script>  
   
 
Regards,  
Ramya T  


Loader.
Live Chat Icon For mobile
Up arrow icon