Skip to content
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

[Bug] In editor: Shortcuts won't work after clicking outside of the active/focused field #185

Open
kvn1351 opened this issue Aug 10, 2022 · 4 comments · May be fixed by #188
Open

[Bug] In editor: Shortcuts won't work after clicking outside of the active/focused field #185

kvn1351 opened this issue Aug 10, 2022 · 4 comments · May be fixed by #188
Assignees

Comments

@kvn1351
Copy link

kvn1351 commented Aug 10, 2022

Hi,
the addon breaks when you click anywhere else than on a field while being in the editor :/
One has to click another field and back to the desired field of choice to reactivate the shortcuts.

Native shortcuts on the other hand, like CMD+B for Bold, continue to work.

I have a hunch that this newly added focusTrap might be causing this (ankitects/anki#1861) but I haven't looked at the code yet.

Also, I've disabled all other addons before testing ofc!

I've made a video to illustrate the issue:

2022-08-11.at.01.16.34.mp4

 

Version Info
macOS Monterey
Version 12.4
Version ⁨2.1.54 (b6a7760c) ⁩
Python 3.9.7 Qt 6.3.1 PyQt 6.3.1
@Liresol Liresol self-assigned this Aug 11, 2022
@Liresol
Copy link
Owner

Liresol commented Aug 11, 2022

Hello,
Based just on the bug report this one might take a while to figure out, but I am able to fully reproduce what's going on in the video.
For the time being, a somewhat ridiculous workaround that I found was to select another field and then select the original field, which restores the shortcut functionality (until clicking away again).

@kvn1351
Copy link
Author

kvn1351 commented Aug 15, 2022

My initial hunch turned out to be right and I've managed to find a solution.

However, I'm not 100% sure that my fix is without consequences. From my understanding of 8270ce1, there was a slight oversite in regards to the shortcut handling. I've gone into detail about it here: ankitects/anki#1861 (comment).

    for row in cuts:
        if len(row) == 2:
            keys, fn = row
            #fn = self._addFocusCheck(fn)
        else:
            keys, fn, _ = row
        scut = QShortcut(QKeySequence(keys), self.widget, activated=fn)

You can just comment this out for now in your monkey patch and it should work fine.

kvn1351 added a commit to kvn1351/anki-custom-shortcuts that referenced this issue Sep 14, 2022
@kvn1351 kvn1351 linked a pull request Sep 14, 2022 that will close this issue
@ghost
Copy link

ghost commented Dec 23, 2022

I've noticed this as well, very frustrating.

@kvn1351
Copy link
Author

kvn1351 commented Dec 23, 2022

I've noticed this as well, very frustrating.

Idk why he hasn't merged it. But you can just use my fork. It works without any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants