I was trying to add shortcut to scripts. Shortcut works once I refresh the plugins.
But when I use some other plugin which uses pcbnew.Refresh() or I do pcbnew.Refresh(), it won’t work as pcbnew by default doesn’t have the plugins in GUI.
Any workaround to run the functions every time pcbnew.Refresh() is invoked??
But you may have more luck if you add your item to one of the sidebars instead of top toolbar or menubar because those are rebuilt often on various triggers. I don’t think sidebars are rebuilt so your custom item should persist.
Proper fix for this would need actual shortcut support for plugins on kicad side.