Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to bind to 'element.mousedown' event when clicking elements. Unable to listen for CMD/CTRL key. #40

Closed
vesper8 opened this issue Mar 6, 2023 · 1 comment

Comments

@vesper8
Copy link

vesper8 commented Mar 6, 2023

I'm wondering if you can provide advice here.

I am trying to listen to CTRL-click / CMD-click when you click on an element, such as a task.

I tried


  modeler.on('element.click', (event) => {
    const element = event.element;

    if (event.originalEvent.metaKey || event.originalEvent.ctrlKey) {
      // do something
    } else {
      // do something else
    }
  });

But it appears that for whatever reason, when you CMD/CTRL click on an element, it does not trigger the 'element.click' event at all.

I tried disabling the keyboard bindings but that did not help.

I also tried with


  modeler.on('element.mousedown', (event) => {
    console.log('element.mousedown.event', event);
    console.log('element.mousedown.event.originalEvent', event.originalEvent);

    const element = event.element;

    if (event.originalEvent.metaKey || event.originalEvent.ctrlKey) {
      console.log('element.cmd-mousedown.element', element);
      console.log('element.cmd-mousedown.element.incoming', element.incoming);
      console.log('element.cmd-mousedown.element.outgoing', element.outgoing);
    }
  });

But it's a similar issue, when I click on an element, such as a task, it does not trigger the 'element.mousedown'
event at all, with or without modifier keys pressed down

I was able to achieve a workaround by listening for the ALT key instead:

  modeler.on('element.click', (event) => {
    const element = event.element;

    if (event.originalEvent.altKey) {
      // do something
    } else {
      // do something else
    }
  });

The above works.. but I was really hoping to use the CMD/CTRL key instead of the ALT key.

Do you know why the above is not working with the CMD/CTRL key? I believe this should work..

Many thanks!!

@miyuesc
Copy link
Collaborator

miyuesc commented Mar 7, 2023

I also tried it and found that it does work as you said.
But the problem is that bpmn.js doesn't support such use, and it's hard for me to make changes here.

@miyuesc miyuesc closed this as completed Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants