IE_Pressed when using BindKey in the UInputComponent not working as expected

Seems a very strange problem or maybe a misconception of mine. I expect that the function would be called when I click the mouse button. But instead it only gets called when I double click, which seems strange.
EInputEvent::IE_Released and EInputEvent::IE_DoubleClick work perfectly.

PlayerInputComponent->BindKey(EKeys::LeftMouseButton, EInputEvent::IE_Pressed, this, &Foo::foo);

there is no other object in the scene that receives inputs. I turned them off in all controllers/ pawns etc. This function is the only place I have bound inputs. There are no mappings in the settings. I recompiled multiple times. I even try to hunt down the problem with the debugger.

I know that is not much to go on but anyone an idea what the problem could be?

edit1: tried it with an action binding. same problem

edit2: even stranger: it works in a completely new project. I started with the first person template. maybe that has something to do with it?

I think the function call should be BindAction. Anyways i do it this way.

In your Editor, Edit->Project Settings->Input

I would add an Action Input With Name Like “Fire” then the key for it say Left Mouse Button.

Then in the C++ SetupPlayerInputComponent() function i would add it this way

PlayerInputComponent->BindAction(“Fire”, IE_Pressed, this, &Foo::foo);

Yeah that “works” as in the inputs “work”. it’s just that the calls to the delegates are somehow mixed up
released-> works as it should
pressed-> doesnt work
double click → calls double click AND released

seems something is completely mixed up in this project

Hey! Perhaps it’s no longer relevant, but i also had such problem, and i think i solved it)
Here what i’ve done to defeat this issue:

  1. in project settings in “Input” go to “Viewport properties” and set in drop down “Capture Permanently Including initial mouse down” or smth like this. “Capture Permanently” is one of the reasons of issue.
  2. In your PlayerController (or may be in other places) class (or BP) when you set input mode use “SetInputModeGameAndUI”, not “SetInputModeGameOnly”.

It works for me, but i suppose i just didn’t figure yet how correctly work with UI management and etc.

Maybe this will be at least helpfull for someone else.

1 Like

yep, it was! thank you!