anki icon indicating copy to clipboard operation
anki copied to clipboard

Sync tooltip focus fix

Open JMannervik opened this issue 1 month ago • 8 comments

 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

JMannervik avatar Nov 03 '25 16:11 JMannervik

It'd be better to move this into tooltip() as Abdo originally said, to address the issue for all tooltips

iamllama avatar Nov 03 '25 17:11 iamllama

Thanks for the feedback! I have centralized it now

JMannervik avatar Nov 07 '25 11:11 JMannervik

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.

abdnh avatar Nov 10 '25 10:11 abdnh

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

JMannervik avatar Nov 14 '25 11:11 JMannervik

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.

abdnh avatar Nov 14 '25 19:11 abdnh

Hmm, yes it seems hard to get a fix for all tooltips...

JMannervik avatar Nov 15 '25 11:11 JMannervik

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 :)

JMannervik avatar Nov 15 '25 11:11 JMannervik

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.

abdnh avatar Nov 17 '25 15:11 abdnh