View Single Post
Old 07-30-2018, 05:13 PM   #1
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,257
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Editor plugin tools & shortcut keys

I have quite a lot of editor plugin tools and up to now have only ever added each tool to one of the toolbars. Each tool also appears under Plugins on the menu. No problems to date.

I don't normally care about shortcut keys (difficulty remembering them) but with my latest tool I thought a shortcut key might be more convenient. The default shortcut key combo I assigned (Ctrl+Alt+Shift+Z) appears in the list under
Edit > Preferences > Keyboard shortcuts > Plugins > MyUnicodeTool
and I can customise it there if I want. It has no conflicts. On the face of it everything appears OK.

However, no matter what I set the shortcut to, the tool is never run. Typing Ctrl+Alt+Shift+Z just types a Z in the editor at the current cursor position.

The tool does run OK via a toolbar button or from the Plugin menu.

I'm wondering if I have the wrong magic combination of settings in the Tool class. I currently have:
Code:
allowed_in_toolbar = True
allowed_in_menu = True

def create_action(self, for_toolbar=True):
    ac = QAction(get_icons('images/unicode.png'), _('MyUnicodeTool'), self.gui)
    if for_toolbar:
        self.register_shortcut(ac, 'get-unicode-tool', default_keys=('Ctrl+Shift+Alt+Z',))
    ac.triggered.connect(self.do_the_action)
    return ac
I have tried various variations in the 3 True/False variables above but haven't found a working combo.

I also tried installing your demo, editor_demo_plugin.zip, the Magnify Fonts tool. I had the same problem with this tool as well. Typing Ctrl+Shift+Alt+D just types a D.

Any idea what I'm doing wrong? What should the settings be to get a working shortcut? Is there some higher level config or tweak I may have unset long ago which could stop plugin shortcuts working.

In case it's relevant, other Editor standard shortcuts, like Ctrl+C, Ctrl+F, Ctrl+N, F7 (Check Book) etc work OK.
jackie_w is offline   Reply With Quote