Sync tooltip focus fix
Prevents the "Collection Sync complete" tooltip from appearing
when the Anki window is minimized or when switching to another
application. The tooltip now automatically closes if the window
loses focus, becomes invisible, or is minimized.
Closes #4188
It'd be better to move this into tooltip() as Abdo originally said, to address the issue for all tooltips
Thanks for the feedback! I have centralized it now
For reference: https://github.com/ankitects/anki/issues/4188
If I run this in the debug console, the tooltip immediately disappears due to the active window check:
from aqt.utils import tooltip
tooltip("hello", parent=mw, period=5000)
I assume this can potentially happen in some places in the code or in add-ons, so we need to handle it somehow.
I think i found a solution for this @abdnh, I updated the focus check to only start monitoring if the window was active when the tooltip was created, so tooltips from the debug console or other tooltips (when Anki isn't active) still appear
There is a case where the tooltip persists despite Anki not being on top. On Windows for example, if I switch to another app without minimizing Anki, the tooltip will stay. I don't know if this is easy to fix.
Hmm, yes it seems hard to get a fix for all tooltips...
I dont have windows so i cant really check, but when i looked online it seems like app.focusWindow() is more reliable on windows. I can try this as a last attemt perhaps :)
Doesn't seem to make a difference.
Hmm, yes it seems hard to get a fix for all tooltips...
Yeah, maybe it's not worth spending more time on it, as the main window will be moved to Svelte in the future.