Allow element to move but it has to stay attached

Hello everyone!

I tried to implement a rule where I allow to move boundary elements along the boundary but it is not allowed to be not attached anymore. So every event has to be attached.
I tried the following:

function canMove(context){
    var shapes = context.shape,
        target = context.target,
        source = context.source,
        position = context.position;
    var businessObject = context.shapes[0].businessObject;
	
    if(target != undefined){
      var targetBusinessObject = target.businessObject;
      console.log(context.shapes[0].host);
      if(context.shapes[0].type === 'bpmn:BoundaryEvent' && (context.shapes[0].host === 'undefined' || context.shapes[0].host === null || context.shapes[0].host)) {
      //if(is(context.shapes[0], "bpmn:BoundaryEvent")){

          return false;
    }}
  }  


  this.addRule('elements.move', 4000, function(context) {
    return canMove(context);  
  });

The problem is that this code forbids the complete movement of events. Has anyone any idea how I can fix it?

Hi @TestUser ,

When you mention moving, do you mean moving with the arrow keys? Than this is the related issue on github:

Unfortunately, the Keyboard Move Selection does not handle attachments at all at the moment. The fix for this is unfortunately a bit more complicated than a rule.

If you want, have a look at the issue. We are always happy about community contributions :smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.