-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Validate Line2D pickradius when setting it, not when reading it. #16134
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
Conversation
@@ -507,7 +504,11 @@ def set_pickradius(self, d): | |||
d : float | |||
Pick radius, in points. | |||
""" | |||
self.pickradius = d | |||
if not isinstance(d, Number): | |||
raise ValueError("pick radius should be a distance") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to move this. But should it also be a positive number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
1e7da60
to
969a485
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please state your opinion on pickradius 0. May self-merge after this.
@@ -507,7 +504,11 @@ def set_pickradius(self, d): | |||
d : float | |||
Pick radius, in points. | |||
""" | |||
self.pickradius = d | |||
if not isinstance(d, Number) or d < 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does a pick radius of 0 make sense? It would trigger only if you hit that pixel. Likely set_pickradius(0)
might be misunderstood as deactivating picking. Anyway, let's not be overly restrictive. -> ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think zero makes more or less sense than 0.001, for example (especially given that GUI toolkits will typically only report events with a precision of 1px anyways), so I wouldn't overly worry about that.
PR Summary
PR Checklist