Adding global editor shortcut key from plugin/editor module

I’ve added a menu extension item to the Window|Developer Tools menu in the editor main window. I’ve set up an FUICommandInfo in my module, and created an FUICommandList, bound the action and passed this command list in to the AddMenuExtension call. It all works fine, except for the keyboard shortcut (defined through an FInputChord in the UI_COMMAND macro).

It’s not clear to me if I need to do something more to get this working. Perhaps use an existing command list from somewhere rather than creating a new one?

I’m now wondering if there’s a more fundamental issue though. I tried adding a keyboard shortcut through editor preferences to the built in engine plugin, ‘Plugin Creator’, which also extends the main menu - and this also fails to work.

Anyone managed to do this?

3 Likes

Hey kamrann,

Were you able to find a solution to this issue.

Regards
Raz

Hi Raz.
Impressive timing, as it happens I had the same question again myself two days ago and searching only brought up my own question here. But I dug into my old code and it seems I did find a solution.
If you bind your commands to the main frame’s command list, it seems to give the desired result.



auto const CmdList = FModuleManager::LoadModuleChecked< IMainFrameModule >("MainFrame").GetMainFrameCommandBindings();
{
  FUIAction const Action(FExecuteAction::CreateRaw(this, &FMyModule::MyHandlerMethod));
  auto const CmdInfo = FMyCommands::Get().SomeCommand;
  CmdList->MapAction(CmdInfo, Action);
}


Assuming FMyCommands is a TCommands-derived type properly registered, and SomeCommand was set up with the UI_COMMAND macro and given a shortcut combo, then the shortcut should work pretty much globally. There seems to be the odd case relating to switching windows where it doesn’t get detected, but on the whole it seems to work.

7 Likes

Hey kamrann,

That seemed to do the trick. Thanks a ton for sharing the solution.

Regards
Raz

1 Like

Thank you so much, @kamrann it did the trick! Saved a lot of time for me as I was searching for hours for the solution.

For other people who might need it:

Additionally it can be confusing some times when short cut appears to be notworking.

In my case I used shortcut that was already taken, so it seamed that function was not called. Strange that there were no conflicts shown when I assigned it in Global Hotkeys window in Editor preferences.

More specifically “V” key worked, while “F” and “D” not