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
{{ message }}
Repository navigation
Changes to cursor position without mouse event #7581
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.
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.
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.
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!
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)...
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!
Activity
tacaswell commentedon Dec 7, 2016
Do any of the 'enter_*' events get triggered this way? We may need to add a 'gets focus' event?
anntzer commentedon Dec 7, 2016
This would not help the case of switching to fullscreen.
tacaswell commentedon Dec 7, 2016
For full screen we have a
resize_eventanntzer commentedon 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 commentedon Dec 19, 2016
We had a similar problem with the pointer when changing tools by shortcut #3474
anntzer commentedon 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
enterEventdoes not passxy=self.mouseEventCoords(event.pos())toenter_notify_event(unlike for other backends) thus losing the coordinates -- but this is an easy fix.github-actions commentedon 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!
anntzer commentedon 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 commentedon 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!
tacaswell commentedon Apr 5, 2024
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 commentedon Apr 5, 2024
Yes. I agree with your analysis above that fixing this probably needs having a gains_focus event.