Download

Is the Editor intercepting my Keyboard Input?

Hi All,

I am trying to add a simple key press input to trigger a function in my **Actor **derived Class.
But I can’t seem to be able to trigger the function. I have tried a few different keys/buttons but they all seem to map to something in the UE4 Editor window. Could the reason they don’t get to my function be that the UE GUI intercepts and doesn’t pass them on?

I have tried both with a blueprint method and a code method but with no luck.

This does not work. (but if I wire up an ‘Event Tick’ instead the function gets triggered fine.)

This is what I am doing in code:

.h


class PROGRAMMINGEXMPL1_API AMyTextureControllerA : public AActor
{
	GENERATED_UCLASS_BODY()

void SetupPlayerInputComponent(class UInputComponent* InputComponent);

.cpp


void AMyTextureControllerA::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
         check(InputComponent);
         InputComponent->BindAction("RandTexture", IE_Pressed, this, &AMyTextureControllerA::RandomizeTexture);
}

But none of these methods seems to work. What am I missing?

Cheers

I realised that I had to also press the ‘Possess’ button next to the ‘Play’ button to be able to send keyboard input! This made the above blueprint setup work.
The code still didn’t work so if anyone could tell me why I would be grateful.

I’m too used to Unity I suppose there’s a lot of things here to figure out. :slight_smile: