The proposed fix works. That is, the shortcuts work, but they are still not displayed in the menu.https://forum.qt.io/topic/15107/solved-action-shortcut-not-triggering-unless-action-is-placed-in-a-toolbar wrote:A shortcut should be triggered if it has a valid parent widget and this parent widget receives events (id est it is not hidden).
To test change the Activated function in InitGui.py to:
Code: Select all
def Activated(self):
"""When entering the workbench."""
if hasattr(FreeCADGui, "draftToolBar"):
FreeCADGui.draftToolBar.Activated()
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.show()
import draftutils.init_draft_statusbar as dsb
dsb.show_draft_statusbar()
FreeCAD.Console.PrintLog("Draft workbench activated.\n")
# Workaround for shortcuts not working for tools in sub menus.
from PySide import QtGui
mw = FreeCADGui.getMainWindow()
for a in mw.findChildren(QtGui.QAction):
if a.shortcut().toString():
mw.addAction(a)