Skip to content

Changes to cursor position without mouse event #7581

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

Open
anntzer opened this issue Dec 7, 2016 · 11 comments
Open

Changes to cursor position without mouse event #7581

anntzer opened this issue Dec 7, 2016 · 11 comments
Labels
keep Items to be ignored by the “Stale” Github Action MEP: MEP22 tool manager

Comments

@anntzer
Copy link
Contributor

anntzer commented Dec 7, 2016

This both affects the current tool system and the MEP22 toolmanager.

The cursor position only gets updated when the canvas detects a cursor motion, which leads to problems 1) immediately after switching fullscreen and 2) if alt-tab'ing to change window focus, moving the cursor and alt-tab'ing back to the original canvas. With either case, the x-y position printed in the status bar is incorrect and it is possible for keyboard shortcuts (e.g.) "g" or "l" to end up affecting a "wrong" axes.

There is a length comment regarding this in the tkagg backend implementation (_update_pointer_position) but even that backend doesn't handle this properly.

Ultimately I think(?) the correct way to solve this is to do away with _lastx/_lasty and just refetch the cursor position whenever a LocationEvent must be emitted.

@anntzer anntzer added the MEP: MEP22 tool manager label Dec 7, 2016
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Dec 7, 2016
@tacaswell
Copy link
Member

Do any of the 'enter_*' events get triggered this way? We may need to add a 'gets focus' event?

@anntzer
Copy link
Contributor Author

anntzer commented Dec 7, 2016

This would not help the case of switching to fullscreen.

@tacaswell
Copy link
Member

For full screen we have a resize_event

@anntzer
Copy link
Contributor Author

anntzer commented Dec 7, 2016

Good point. I think hooking both resize_event and focus_event works better than refetching the cursor position before emitting any LocationEvents as the latter mechanism is probably(?) insufficient to update the status bar text.

@fariza
Copy link
Member

fariza commented Dec 19, 2016

We had a similar problem with the pointer when changing tools by shortcut #3474

@anntzer
Copy link
Contributor Author

anntzer commented Apr 9, 2017

Another case is when an animation changes e.g. the x or y limits. To cover this case, as well as the previously mentioned ones, it looks like we could hook draw_event (which should get called upon resize too?) and focus_event.

Another observation: when the window is resized or displaced, it is actually necessary to refetch the mouse position, as Qt reports it relative one of the window corners. So if one hooks draw_event hoping of covering resizes too, when the draw_event occurs, _lastx and _lasty will still be defined relative to the earlier window size (as that was the window size when the last mouse event occured), and thus will be incorrect (e.g. they will then be converted to xdata/ydata using the new window size).

Also note that 1. Qt triggers an exit and an enter event upon un-maximizing window size, but the current implementation of enterEvent does not pass xy=self.mouseEventCoords(event.pos()) to enter_notify_event (unlike for other backends) thus losing the coordinates -- but this is an easy fix.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Sep 24, 2017
@github-actions
Copy link

github-actions bot commented Apr 3, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 3, 2023
@anntzer
Copy link
Contributor Author

anntzer commented Apr 4, 2023

Triggering a cursor update on a resize_event seems easy enough to do and should hopefully(?) be uncontroversial. Adding a focus_event may be a bit more work (perhaps gain_focus_event/lose_focus_event? -- needs checking what most GUI toolkits offer)...

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label Apr 5, 2023
Copy link

github-actions bot commented Apr 5, 2024

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 5, 2024
@tacaswell
Copy link
Member

We have now deprecated LocationEvent.lastevent (and it can be fully pulled out as soon as 3.9.x is brnached). Does this problem still reproduce?

@anntzer
Copy link
Contributor Author

anntzer commented Apr 5, 2024

Yes. I agree with your analysis above that fixing this probably needs having a gains_focus event.

@tacaswell tacaswell added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Items to be ignored by the “Stale” Github Action MEP: MEP22 tool manager
Projects
None yet
Development

No branches or pull requests

3 participants