jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.65k stars 722 forks source link

Clicking on connection ask for it properties and right click on connection delete #365

Closed 1989levinu closed 2 years ago

1989levinu commented 2 years ago

now i have called one method on editor.on('connectionSelected', function (connection) { setproperties(); } but i have to delete the connection on right click as normal.

how can i do this.. since connectinSelected event is get invoked both on right click and normal click

jerosoler commented 2 years ago

Hello,

You can detect the right click like so:

    editor.on('clickEnd', function(event) {
      if(editor.connection_selected !== null && event.button === 2) {
          alert("Right Click connection");
      }
    })
1989levinu commented 2 years ago

can i get this event inside connectionSelected event. My need is if it is regular click show connectionProperties and if it is rightclick invoke delete..[right click delete i'm using the current built-in functionality of drawflow.js].but my concern is when the connection is selected.inisde that event(connectionSelected event) ,i need to check whether it is normal click or right click.

jerosoler commented 2 years ago

The connectionSelected event does not return the event.

You can use the "click" or "clickEnd" event to save the button that is clicked. To then call the clicked button something similar to this:

    let buttonClick = null;
    editor.on('click', function(event) {
        buttonClick = event.button;
    })

    editor.on('connectionSelected', function (connection) {
        alert(buttonClick);
    })
1989levinu commented 2 years ago

Thanks:-)