joferkington / mpldatacursor

Interactive "data cursors" (a.k.a. annotation pop-ups) for matplotlib
MIT License
194 stars 47 forks source link

allow mpldatacursor to ignore specified mouse keys #22

Closed joe-louderback closed 10 years ago

joe-louderback commented 10 years ago

In a program, I used a right-click on the DataCursor popup to close it. Since there were a lot of data points, this right click could trigger another pick event which opened a new DataCursor popup. This patch lets DataCursor ignore certain mouse keys if desired.

joferkington commented 10 years ago

Thanks a bunch for this! (I thought I added a comment when I merged it, but apparently I deleted the comment accidentally.)

joferkington commented 10 years ago

I actually decided to do this a slightly different way. I just made the behavior you're describing (right-click hides) the default and added two kwargs to control which mouse button displays/hides the annotation boxes. To disable right-click hiding, you'd just pass in hide_button=None.

Now annotation boxes will only be displayed on left-clicking (configured through the display_button option) instead of on any mouse click. It's change in behavior, but I think it makes more sense.

Because of that, the ignore_buttons kwarg seemed redundant, so I removed it, though I made sure to give you credit for the overall idea in the changelog.

Have a look at https://github.com/joferkington/mpldatacursor/commit/a84218aa74add491de2818fb355863944c0b034b and let me know what you think.

Thanks again!

joe-louderback commented 10 years ago

I think it's much cleaner than my initial hack (the code I had to hide the cursor was pretty ugly since I did it outside the class). I will be updating my own program with this, so I guess I really like it :-)

On Sat, Apr 26, 2014 at 11:55 AM, joferkington notifications@github.comwrote:

I actually decided to do this a slightly different way. I just made the behavior you're describing (right-click hides) the default and added two kwargs to control which mouse button displays/hides the annotation boxes. To disable right-click hiding, you'd just pass in hide_button=None.

Now annotation boxes will only be displayed on left-clicking (configured through the display_button option) instead of on any mouse click. It's change in behavior, but I think it makes more sense.

Because of that, the ignore_buttons kwarg seemed redundant, so I removed it, though I made sure to give you credit for the overall idea in the changelog.

Have a look at a84218ahttps://github.com/joferkington/mpldatacursor/commit/a84218aa74add491de2818fb355863944c0b034band let me know what you think.

Thanks again!

— Reply to this email directly or view it on GitHubhttps://github.com/joferkington/mpldatacursor/pull/22#issuecomment-41477388 .