Include elements created by contextpad in a "create rule"

I have added 3 customRules the first two are working fine.
But the third ‘shape.create’ action rule doesnt trigger when the element is created by the contextpad, but it does work when adding elements from the palette.

  • Is there another alternative action that could be triggered when an element is created by both methods?

   this.addRule('connection.create',2000, function(context) {
    if (context.source.id===context.target.id){
      return false;
    }
  });

  this.addRule('elements.delete',2000, function(context) {

    if (context.elements[0].id==="StartEvent_1" || context.elements[0].id==="EndEvent_1"){
      return false;
    }
  });
  
  
  this.addRule('shape.create',2000, function(context) {
    //this rule is note working if the element is created from contextpad
    console.log(context);
  });
 
  • Is it also possible to stop the default behavior of selecting an element on creation(that allows to change element’s label, and shows its contextpad)?

EDIT: added a sandbox link

Could you share your sandbox again, if you’re still working with it?

I updated my sandbox project.
Try to create a task from the startEvent’s context pad it doesnt trigger the shape.create rule, whereas adding a task from the palette does trigger it.


update:
I tried adding this listener (added in the sandbox too):

eventBus.on(["create.end", "autoPlace.end"], 2000, function () {
      //directEditing.cancel();
      return false;
    });

it works for the contextpad but the “create.end” doesn’t allow adding a task from the palette now :sweat_smile:

I was able to fix my problem using this reply:

I tried something similar before but had a higher priority (2000) and setting it to something like 499 fixed my issue.