-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FigureCanvasQT key auto repeat #6302
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
FigureCanvasQT key auto repeat #6302
Conversation
Add to "keyPressAutoRepeat" and "keyReleaseAutoRepeat" properties to FigureCanvasQT. If True, enable key auto-repeat for press and release events respectively.
Shouldn't the press and release events always have the same 'auto' status? Seems reasonable enough other wise. Why have the |
attn @mfitzp |
I split press and release events in 2 status to have more flexibility. I don't know why auto-repeat was disabled in Qt-back-end, but I think it is for a good reason. Therefore, I change only the press status when really needed in my application, and reset it to default with the final release event. An alternative could be to have only one status, but have a "isAutoRepeat" property on Matplotlib events. But I don't know if other backends can return this information. Previously, |
Thanks for your contribution @JGoutin I'm also not entirely sure why auto-repeat was disabled on the backend but I suspect it may have been to avoid generating a large number of events (e.g. when holding down zoom). But I wonder if the recent changes to redrawing ( For the PR I have similar questions:
@tacaswell I'm not sure |
On 2016/04/14 11:11 PM, Martin Fitzpatrick wrote:
To clarify: you are referring to the zoom/pan behavior in which holding |
Key auto-repeat for push and release in one attribute. Auto-repeat On by default for QT5.
Key auto-repeat Off by default for QT4.
I changed status to be an instance attribute and for work on press and release events at the same time. After some tests, I didn't find any problem for enabling auto-repeat permanently. This is maybe because Qt4 is not really efficient on drawing (Auto repeat event drawing was slow and unresponsive on my test). But it is not the case for Qt5. So, I make auto-repeat ON by default for Qt5 and OFF by default for Qt4. @mfitzp :
|
@efiring I don't think this affects the Pan/Zoom — it's related to catching keyboard events for custom handling of plot interaction (e.g. if you bound right-arrow to pan right, without the auto-repeat you would need to keep jabbing the key). The following snippet shows the effect on the events:
With this patch, pressing a key results in "you pressed" being printed repeatedly the console. On current master, you just get the one notice. @JGoutin Thanks again for making the changes, testing it here everything looks perfectly fine! The only outstanding question I have is with the difference in behaviour between Qt4 and Qt5. The two Qt backends are designed to function as exact drop-in replacements so a difference in behaviour isn't ideal. My vote would be to have it turned off by default in both Qt4 and Qt5. Thoughts @tacaswell @efiring? Having tested this with Qt4 (change |
For some (all ?) other backends, behavior is auto-repeat "ON" because there is no difference between Repeated or first key press. Is it maybe more ideal to have the same default behavior on Qt ("ON" also for Qt5 and Qt4) ? |
If everything else defaults to 'on' qt should also default to 'on' (unless we find a compelling reason otherwise). @JGoutin If you triggering draws, always use attn @pwuertz due to your work on qt performance recently. |
Seems reasonable, and I'm not seeing any regressions when zooming + key press. |
@tacaswell Yes, it's exactly for this (move an artist, with arrows). Thanks for the tips! I set |
I've now tested this on PyQt 4 & 5 and PySide (the former two on Mac, Linux, Windows, the latter on Mac) and can't see any problems resulting from this change with default set to on. My vote is to merge. @tacaswell remind me, does this need to be rebased to a single commit, or can I merge as-is? |
Merge as is On Sun, May 8, 2016, 04:00 Martin Fitzpatrick notifications@github.com
|
Actually, with QtBackend, auto-repeat is disabled. But auto-repeat is sometime useful (By example for implementing moving an artist with arrow keys).
This add "keyPressAutoRepeat" and "keyReleaseAutoRepeat" properties to FigureCanvasQT.
If True, theses properties enable key auto-repeat for press and release events respectively.
With this auto-repeat is still disabled by default, but can be re-enabled now.