World Widget Interaction Problem with buttons in Unreal engine 5.1

Hi,

I’ve been using widget interaction to interact with world widgets in my project, but after updating unreal engine 5.1 it works a little differently.

As you can see in the video, after interacting with a button once, it no longer responds to the interaction until I interact with another widget. It seems like some sort of focusing (Although “is Focusable” is off for the button). I didn’t have this problem in unreal engine 4.27 and 5.0. Is there some new change to buttons or Widget interaction that I’m not aware of?

I’m running into the same issue after upgrading to 5.1. My widget component window is set not to receive focus.

I found this on Unreal Slackers Discord

c++: FSlateApplication::Get().SetAllUserFocusToGameViewport();
blueprint: Set Focus to Game Viewport | Unreal Engine Documentation

My code to click is:

const FKey LeftMouseButtonKey = FKey(EKeys::LeftMouseButton);
PressPointerKey(LeftMouseButtonKey);
ReleasePointerKey(LeftMouseButtonKey);
FSlateApplication::Get().SetAllUserFocusToGameViewport();

and it seems to work as before now.

2 Likes

Thanks, it solves the important part of the issue. Unfortunately though, just like setting the input mode to FInputModeGameOnly, after the first interaction the button style stays as “Pressed”, But that’s okay for my project.

[UE 5.1.0] For anyone else having the same problem, make sure that:

  1. You’re using “onPressed” (not “onClicked”) event for your buttons
  2. After sending interaction to the widget, use either of these methods depending on your project:
  • a. [Thanks to StormX31211] FSlateApplication::Get().SetAllUserFocusToGameViewport();
  • b. YourController->SetInputMode(FInputModeGameOnly());
  1. Set onPressed style of your button same as the normal style

I have the same problem, but unfortunately the suggested workarounds do not fully solve the problem:

After setting the focus to the game viewport everything works fine except clicking inside EditableTextBoxes. The cursor is placed, but focus is then lost and I can’t enter any text.

Does anyone have other suggestions?

Don’t Set focus to the game viewport when the player interacts with the widget, let the player enter the text then use the “OnTextCommitted” event to call “SetInputModeGameOnly” on the player controller (After entering text, you should commit it (By pressing Enter key, or any other way)).

Also, you should call this function for buttons in the “OnPressed” event.

I don’t think this is an option for me, as I have a UI with multiple text boxes and the user should be able to just select the next text box with the WidgetInteraction.

The focus problem was fixed for me by switching to the new EnhancedInput system. It also did only work after creating and setting the ‘Mappable Input Config for XR’.

I’m still having an issue with SendKeyChar() not working this way, so this is not a full solution.

@anon33985116 I’m working through the same issue right now, what do you mean by “Mappable Input Config for XR”?

It looks like [Unreal Engine Issues and Bug Tracker (UE-166377)] is the official report for this issue.

@andreyrd1 It’s in the project settings under ‘Plugins - OpenXR input’ if you have the OpenXR plugin active. The setting is probably only relevant if you are developing for VR / XR.

The problem is caused by this commit.

Reverting the commit fixes the problem for my use case and fully restores the old behavior, but I’m not sure about other scenarios and what the commit was trying to fix in the first place.

This obviously only works, if you’re using a source build of Unreal Engine.

1 Like

@VictorLerp I’m not sure who should be looped in on this, but in my searching as I’ve dealt with it I’ve found a fair amount of comments regarding this issue, and it seems like undesired or undocumented behavior change. If you know who would know more, or if you know more about this bug (?), can you follow up? *tagging you since you’ve worked with OpenXR and VR implementation previously… thank you.

We’re aware of the issue, it’s not intended behavior. You found the public issue that’s tracking it: Unreal Engine Issues and Bug Tracker (UE-166377)

2 Likes

I don’t know if my problem is exactly the same as described here.

Context:

  • I work on OpenXR app, recently upgraded from Unreal Engine 4.27 to 5.1 that use the “old” input system, I have started my project from UE 4.27 OpenXR Template.
  • I maked a World UI with two buttons and want to interact with it with my controllers.

The issue I experiment:

  • When I call “Release Pointer key” on Widget Interaction Right/Left, my Unreal Window is unfocused, so I can’t interact with my app anymore with my controllers unless I maked Alt+Tab and manually re-focus my windows with my mouse.

My solution:
call function “set Focus To Game Viewport” after I call “release pointer key”

2 Likes