-
Notifications
You must be signed in to change notification settings - Fork 21
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
Re-focus on cursor using mouse click #34
Comments
That's a great idea, now implemented on master. Please give it a try. |
Thanks! |
Please provide a full description of how to reproduce the issue. |
OK, after reviewing my code, I think understand what happened... There's another issue where if I have more than one plot on my canvas, the last cursors marked on all plots are always active. So if I choose one cursor on plot 1 and another on plot 2, they will both be active simultaneously and I can shift them around using my keyboard. I only want to shift one cursor at a time, so my workaround was that I programmatically change the bindings on all cursors but the last one. However, this means that I can't go back to previous cursors using your new feature. Any ideas how to improve? Thanks again! |
I pushed another change that makes |
Thanks, that works. It took me a while to figure out that pick_event refers to the matplotlib package and not mplcursors. I run it through mpl_connect and it works well. However, I don't think I can use cursor.enabled, because that also disables new cursors from registering for a particular plot. So I've kept the binding workaround for now. I'll be happy to know if you think there's a better, more elegant solution. I have one more question - is there a way to define other binding keys, such as the DEL key to delete an active cursor? Thank you for your help. |
To be honest, not much thought went into the interaction between multi-cursors and keybindings, because I didn't need that. So I don't have anything great to propose right now.
Not right now (because until your proposal there wasn't even a notion of "current" cursor -- again, multi-cursors were sort of a side-feature), but I'd be open e.g. add a |
I'd be happy to help, although I will need an explanation of how to do it properly, since I do not have much experience with PRs or Git. :) I think the entire issue around active cursors is potentially something to work on, but is not necessarily relevant to my bindings suggestion. Anything defined in bindings works on all active cursors, so defining a keyboard DEL key will essentially just have the same functionality as mouse button 3 for all active cursors. For now, I can use my workaround to define different bindings for the 'delete' function in order to make sure that only my "active" cursor will actually be deleted using DEL. I think active/inactive cursors should be about modifying the status of a particular selection. Maybe the best way would be to change the default behavior so that only the last created selection is active and all others are inactive unless clicked on. I do think it's best to have only one cursor active at a time, unless defined otherwise. How does that sound? |
For instructions on git/prs/github, consider checking matplotlib's contribution docs (https://matplotlib.org/stable/devel/contributing.html), including their gitter channel. |
Hi, I've added the following features to my version of the mplcursors code, which I find very useful:
I'd be happy to get your opinion. In addition, I would really like to graphically mark the active cursor by changing the style of the annotation box. I'm trying to achieve this by using the following for the add callback:
So active annotations are with linewidth=1 and inactive (existing) annotations with linewidth=0. |
1) and 2) seem fine (though things may need to be clarified regarding how your "enabled" attribute differs from the already existing Cursor.enabled). As for the last question, I think you need to call |
Regarding (2), I wrote ENABLED, but actually the new property name is ACTIVE, and is only relevant to bindings. If I am not mistaken, ENABLED = False also disables new selections from being generated. I think those are two different functionalities... but maybe they shouldn't overlap? Regarding (3), I've changed the Selection.button field to Selection.event, which now includes the general event used to add the selection - MouseEvent, KeyEvent, etc... figure.canvas.draw_idle() is working! Thanks! |
I guess so. One of the things that slightly worry me is simply the complex interaction between all the features here; some table summarizing all the possible combos may help. |
Hi,
Love mplcursors! When I add a second cursor to my canvas, I can move it around using keyboard bindings, which is great. However, I can not shift the focus back to my first cursor by clicking on it. Is there anyway to do that?
It works well for draggable annotations. I can drag any annotaion I want on the canvas, whether it is associated with the first or second cursor. I was hoping there was a way to define that if I click on an existing annotation/cursor, it shifts the focus to the cursor, and I could also shift/drag it along the plot using keyboard/mouse.
Thanks!
Orel.
The text was updated successfully, but these errors were encountered: