draw2d icon indicating copy to clipboard operation
draw2d copied to clipboard

How to disable click to add vertex to a polygon

Open vinhhungle opened this issue 2 years ago • 6 comments

Currently, when clicking on a polygon line, it will add a vertex. I'm trying to find a way to disable this behavior. Is there anyway to do this? Thank you for your help!

vinhhungle avatar Apr 10 '22 04:04 vinhhungle

everything in draw2d is managed by EditPolicies .

  • SelectionFeedback via rectangles, lines,...
  • DragDrop Behaviour
  • Copy&Paste
  • Interaction with Connections,
  • Zoom or Panning

and of course the edit behaviour of polygons. You can just install another EditPolicy to get the expected behaviour.

Example: https://codepen.io/freegroup/pen/PoEaRvj

freegroup avatar Apr 10 '22 16:04 freegroup

There is no policy related to click-to-add vertex behavior. However, I've found a work around. Thanks.

vinhhungle avatar Apr 28 '22 13:04 vinhhungle

did you check my sample? There is.

freegroup avatar Apr 28 '22 13:04 freegroup

Yes, I've seen it. However, the requirement for my case is different. I still need the original vertices to be editable but I don't need the click-to-add vertex behavior. So my current workaround is to add an attribute to the original vertices and remove any vertices without that attribute.

vinhhungle avatar Apr 28 '22 14:04 vinhhungle

the best is to implement your own SelectionHandler instead of removing the points after user-edit. It is possible to manage almost everything via Policies.

I Update the example with your requirements

https://codepen.io/freegroup/pen/PoEaRvj

I think the shape in the middle fits best your needs.

freegroup avatar Apr 28 '22 14:04 freegroup

Got it. Thank you for your help!

vinhhungle avatar Apr 28 '22 14:04 vinhhungle