Can I add command/hotkey to the Blueprint Editors SEditorViewport from a Plugin?

Hi, Im writing an editor plugin that adds some basic transformation tools - I noticed that commands like translate/rotate/scale is added by appending directly to SEditorViewport::CommandList in SEditorViewport::BindCommands() - so I naively had a go at doing the same via SEditorViewport::GetCommandList().Append() on a SEditorViewport instance whilst the editor was well up & running - but this resulted in an invalid memory access due to SEditorViewports CommandList lacking a FUICommandList “parent” (I dont remember the name of the attribute on the top of my head, but it was something with parent).

So to my question:

Does anyone know of any code samples or plugins that appear to be able to bind commands to the Blueprint asset editor’s 3D viewport or alternatively all viewports in the engine (2D & 3D)?

Thanks for reading :gift_heart:

You can write an IInputProcessor which captures input before it is processed by the engine. This way you can trigger certain actions/behavior when a shortcut is triggered.

Here is a sample:

#pragma once

#include <Framework/Application/IInputProcessor.h>

class FExample : public IInputProcessor
{
public:
	virtual void Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> Cursor) override{};
	virtual bool HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InKeyEvent) override;
};
bool FExample::HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InKeyEvent)
{
	// check for your input
	// return true if you want to prevent the engine from handling the input, false otherwise.
	return true;
}

and to register it inside the StartupModule you need to:

InputProcessor = MakeShared<FExample>();
FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor, 0);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.