Bug: Mac OS shortcuts don't always work with plugin menu items

64 views
Skip to first unread message

Waleed Dahshan

unread,
Oct 3, 2024, 12:17:49 AMOct 3
to zotero-dev
I have created my own Zotero personal plugin based on the make-it-red sample plugin and I added a few menu-items of my own to the "View" menu. Now as I want to use these menu-items I have used Mac OS native keyboard shortcuts settings to map some keyboard shortcuts to these menu items.

However, the problem is that the shortcuts do not start to work until I have opened the View menu every time I start the app. So I have to go to the menu bar, click on View, before the shortcuts start to work.

I am using Zotero 7.

Waleed Dahshan

unread,
Oct 3, 2024, 2:48:58 AMOct 3
to zotero-dev
Note that event the make-it-red sample plugin suffers from this issue as well. If you assign a shortcut to the command "Make It Green Instead", and restart Zotero, then the shortcut doesn't work until I click "View" in the menu bar.

XY Wong

unread,
Oct 3, 2024, 4:02:12 AMOct 3
to zotero-dev
Could you please share the code?

Waleed Dahshan

unread,
Oct 3, 2024, 4:18:34 AMOct 3
to zotero-dev
Well even Zotero's own sample plugin make-it-red can be used to demonstrate the bug:

Install the XPI, then go to Mac settings -> keyboard -> shortcuts -> application shortcuts -> Zotero
The menu item is "View->Make It Green Instead"

My specific project is:
and has the same problems.




XY Wong

unread,
Oct 3, 2024, 5:03:42 AMOct 3
to zotero-dev
The menu items inside the menu popup added by the plugin are dynamically initialized after its first opening. That's why you are seeing this.

If you want to trigger something with a shortcut, you can either add a keyboard event listener to the main window or use the XUL's keyboard binding element <key> (Zotero uses both).

Waleed Dahshan

unread,
Oct 3, 2024, 5:26:18 AMOct 3
to zotero-dev
That was my suspicion but their ought to be a way for Zotero to synchronise the system shortcuts after all plugins have been loaded. Though I don't know how that would be easily achieved.
Reply all
Reply to author
Forward
0 new messages