draw2d
draw2d copied to clipboard
How to disable click to add vertex to a polygon
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!
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
There is no policy related to click-to-add vertex behavior. However, I've found a work around. Thanks.
did you check my sample? There is.
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.
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.
Got it. Thank you for your help!