You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create legend that can toggle the visibility of each drawn object. Here is my code. It works on the line legend, but clicking on the dot legend object doesn't toggle the drawn object. In contrast, clicking outside the dot legend object will toggle the drawn object. This is counter-intuitive from the use perspective. Does anyone has any workaround to this issue?
The problem is that when the legend creates the handles for a Line2D, it actually creates two things, one for the line and one for the marker (I assume to handle the numpoints option). However, for some reason, with any handle consisting of multiple artists, legend only ever returns the first thing. So you've only enable picking on the line part (which is invisible here) and the marker is above that without picking enabled.
I guess what is needed is a "MultiArtist" which could encapsulate the line + marker, draw both, and forward any properties to the latter. I'm not sure if there is any workaround at this time.
I found a small trick from stack-overflow. Setting the pick-radius of the dot_legend to 15 solve this problem.
dot_leg.set_pickradius(15)
Now I am wondering which object is on top, line or marker? Why it didn't work at pick-radius = 5.
If the marker is not pickable and the invisible line is always sit above the marker, then why it didn't work at pick-radius = 5?
In contrast, if the marker is above the invisible line, how come a bigger pick radius make it works? I thought the pick-radius only affect the line, but we shouldn't be able to pick the line because it's covered by the marker, right? In this case however, clicking at the center of the marker actually works at pick-radius = 15.
🤔 Any hints on how it work? Really hope that I don't have to study the source code to find out.
I am trying to create legend that can toggle the visibility of each drawn object. Here is my code. It works on the line legend, but clicking on the dot legend object doesn't toggle the drawn object. In contrast, clicking outside the dot legend object will toggle the drawn object. This is counter-intuitive from the use perspective. Does anyone has any workaround to this issue?
The text was updated successfully, but these errors were encountered: