Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable click to add vertex to a polygon #209

Open
vinhhungle opened this issue Apr 10, 2022 · 6 comments
Open

How to disable click to add vertex to a polygon #209

vinhhungle opened this issue Apr 10, 2022 · 6 comments

Comments

@vinhhungle
Copy link

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!

@freegroup
Copy link
Owner

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

@vinhhungle
Copy link
Author

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

@freegroup
Copy link
Owner

did you check my sample? There is.

@vinhhungle
Copy link
Author

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.

@freegroup
Copy link
Owner

freegroup commented Apr 28, 2022

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.

@vinhhungle
Copy link
Author

Got it. Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants