freegroup / draw2d

Create Visio like drawings, diagrams or workflows with JavaScript and HTML5
https://freegroup.github.io/draw2d/#/examples
MIT License
741 stars 228 forks source link

multiple selections with PanningSelectionPolicy #141

Open akoskm opened 4 years ago

akoskm commented 4 years ago

Is there any way to support multiple selection with PanningSelectionPolicy?

Ideally, I would like to have BoundingboxSelectionPolicy installed and I would like the selection to being when I press Shift.

If this is not doable I'm OK with selecting multiple elements, one-by-one, while holding Shift.

akoskm commented 4 years ago

Can I get some feedback here, is this supported @freegroup?

Samanoova commented 3 years ago

I have created a custom function to do that while pressing the shift key I detect the click event on the node then added a selection to the canvas or get the current selection as an ArrayList then added the node then set the current selection with the new array

akoskm commented 3 years ago

Can you share some code here?

Samanoova commented 3 years ago
let myCanvasPolicy = draw2d.policy.canvas.CanvasPolicy.extend({
  name: "MyCanvasPolicy",
  shiftSelection: new draw2d.util.ArrayList(),
  allowdSwimLane: null,
init: function(attr, setter, getter) {
    this._super(attr, setter, getter);
  },
onMouseUp: function(canvas, x, y, shiftKey, ctrlKey) {
let bestFigure = canvas.getBestFigure(x, y);
if(shiftKey==true){
// then you can use canvas.addSelection(bestFigure); or some thing like that 
}
}
})

then install the policy to your canvas

akoskm commented 3 years ago

Thanks, I'll give this a try. 🙇