Because it was actually hard to figure out why the BackHandler doesn’t work in Common UI plugin I decided to store all the information that we found and that helped us to make it work
-
Widget that has common activatable widget stack component should not be Activatable widget but rather CommonWidget.
-
Create Custom GameViewportClient with DefaultConstructor in your project and set it as default in project settings in GameViewportClientClass.
// .h
UCLASS()
class YOURGAME_API UMyGameViewportClient : public UCommonGameViewportClient
{
GENERATED_BODY()
UMyGameViewportClient();
};
// .cpp
UMyGameViewportClient::UMyGameViewportClient() : Super()
{
OnRerouteInput().BindUObject(this, &UCommonGameViewportClient::HandleRerouteInput);
OnRerouteAxis().BindUObject(this, &UCommonGameViewportClient::HandleRerouteAxis);
OnRerouteTouch().BindUObject(this, &UCommonGameViewportClient::HandleRerouteTouch);
}
- Check “Is back Handler” on activatable widget.
- Check “Is Modal” on activatable widget.
- override OnHandleBackAction inside your activatable widget and put print string to test.
- override Get Desired Focus Target inside your activatable widget.