FReply Handled has changed behaviour in 4.8

Hey, we had a nice working UI that pretty much broke down with the move to 4.8. This is the problems we have discovered so far… they don’t make sense to us at all.

We have an inventory screen that should disable input to the game. In 4.7 we used InputMode UI Only and then implemented OnKeyDown and returned FReply::Handled. This caused the key event to never be forwarded to the game. In 4.8 when we close the inventory screen via OnKeyDown the same key press is still coming to the game even though FReply::Handled is returned from it.

FReply::Unhandled and FReply::Handled within the UMG Hierarchy behaves very strange. In one case when we return FReply::Handled the event still get forwarded to the parent, and in another case return FReply::Unhandled does not get forwarded.

And finally, kismet library function IsShiftKeyDown causes a crash when used inside OnKeyDown.

Yes, that is one way to do it with an inventory screen and we already have a similar solution.

The question was actually about FReply::Handled and Input mode UIOnly. What is the correct functionality for them? If you have set UIOnly and return FReply::Handled from OnKeyDown should the input events still be forwarded to the main game?

Hey Markus-

You may want to take a look at the tutorial video for setting up input for your pawns. The main idea is that the input function itself should check if the inventory is open and if so ignore the rest of the input function. The check inside your function would look something like this:

if(bOpenInventory)
{
     return;
}
else
{
     //rest of input function
}

This way you can set the bOpenInventory boolean when the inventory screen is opened/closed and the input command will respond accordingly.

Cheers

Doug Wilson

Hey Markus-

If I understand correctly you’re saying that input is being registered by the game when Input mode UIOnly is set, correct? Can you elaborate on how you are setting up the input and calling OnKeyDown/FReply::Handled as well as what effects you experience in game?

We create a new widget in a playercontroller blueprint and then adds the widget to the viewport and then set input mode UI only. In the widget we use OnKeyDown and FReply:Handled and SetKeyboardfocus. This all worked in 4.7 but stopped working in 4.8. Freply:Handled does not behave in a consistent manner and the root widgets input are forwarded to the game even if FReply:Handled is returned.

Hey Markus-

We’ve not heard from you in a few days and for tracking purposes I will be marking this as resolved. If you’re still having problems using FRepl::Handled feel free to comment here to reopen the post and we will continue investigating.

Cheers

Doug Wilson

I just replied actually. I can give you a link to our project, too.

It was a bug inside of SObjectWidget.cpp, i’ll look into porting them to a hotfix. The IsShiftKeyDown crash is a much nastier problem, it’s an issue with the way the blueprint VM handles structs, specifically structs with inheritance. We’ve got a fix for it, but that part wont be in until 4.9.

Awesome, can we grab this fix on Github?

https://github.com/EpicGames/UnrealEngine/commit/eff899fbb8d3e580ec89654cd8a851c5b56635ec