WasInputKeyJustReleased not working when widget has keyboard focus ?

uced
Fri, 10 Mar 2023 07:34:39 +0000
Programming & Scripting

Hello,

I have to manually manage the focus between viewport and various widgets.
I’m setting/unsetting the focus with calls like those:

hoveredWidget->GetWidget()->SetKeyboardFocus();
FSlateApplication::Get().SetUserFocusToGameViewport(0, EFocusCause::SetDirectly);

And i’m using the player controller’s functions to check which inputs are up/down:

WasInputKeyJustPressed(EKeys::LeftMouseButton)
WasInputKeyJustReleased(EKeys::LeftMouseButton)
IsInputKeyDown(EKeys::LeftMouseButton)

And the likes.

My problem is that as soon as i set the keyboard focus on a widget, the PC’s functions cease to work correctly and give incorrect information.
For example, IsInputKeyDown gives a false while i’m pressing the button, WasInputKeyJustRelease is called right after i click the button, things like that.

I suspect somehow the widget stop propagating the info to the PC, or maybe setting the focus automatically releases the mouse button ?

Anyway, is there a way to have those function correctly working independantly of who has the focus ? Like forcing the widget to let the info get to the PC, or trap the info before it gets caught by the widget ?

Thanks
Cedric

2 posts - 1 participant