Common UI - Changing the confirm input

Hi there, I’m setting up Common UI for my game by following the Inside Unreal video on it, everything is working except for one issue I can’t seem to fix - the Input Action Table isn’t setting my confirm button, instead it’s stuck on the default (space or gamepad face button bottom). My settings for the back button in the same table are working fine and I can change that to whatever I like, but my settings for confirm get completely ignored. Any suggestions?

3 Likes

I’m having the same issue. Gone though every step in the setup of the project but can’t figure this out.

1 Like

We found the problem why the Enter button does not trigger the OnKeyUp Event for CommonButton but the space button does. It seems like the Epic developers don’t want to propagate the event down the Enter event for a Common Button. You can find the code snippet that disables it inside the CommonButtonTypes.cpp line 138.
This is the snippet:

FReply SCommonButton::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
{
	if (InKeyEvent.GetKey() == EKeys::Enter)
	{
		return FReply::Unhandled();
	}
	return SButton::OnKeyUp(MyGeometry, InKeyEvent);
}

This would propagate the event to SButton::OnKeyUp:

FReply SButton::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
{
	FReply Reply = FReply::Unhandled();

	if (IsEnabled() && FSlateApplication::Get().GetNavigationActionFromKey(InKeyEvent) == EUINavigationAction::Accept)
	{
		const bool bWasPressed = bIsPressed;

		Release();

		if ( PressMethod == EButtonPressMethod::ButtonRelease || ( PressMethod == EButtonPressMethod::DownAndUp && bWasPressed ) )
		{
			//execute our "OnClicked" delegate, and get the reply
			Reply = ExecuteOnClick();

			//You should ALWAYS handle the OnClicked event.
			ensure(Reply.IsEventHandled() == true);
		}
		else
		{
			Reply = FReply::Handled();
		}
	}

	//return the constructed reply
	return Reply;
}

This then checks if the KeyEvent key matches Unreals ActionsKeys:

EUINavigationAction FNavigationConfig::GetNavigationActionForKey(const FKey& InKey)

Our Solution was to write a Custom Key Up event inside our own CommonButton:

FReply UBGButtonBase::NativeOnKeyUp(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent)
{
	if (FSlateApplication::Get().GetNavigationActionFromKey(InKeyEvent) == EUINavigationAction::Accept)
	{
		if ( PressMethod == EButtonPressMethod::ButtonRelease || ( PressMethod == EButtonPressMethod::DownAndUp) )
		{
			HandleButtonClicked();
		}
	}
	return Super::NativeOnKeyUp(InGeometry, InKeyEvent);
}
4 Likes

I’d really like to know the reason behind this, because this made me waste way too much time!
Thank you for your solution, I would have never figured it out by myself!

I’m also having a similar issue and I’m not sure I understand the solution.
I wasn’t able to change the ‘confirm’ button and it doesn’t seem to trigger the ‘OnKeyDown’ event, so as it is I am forced to use one button (OnKeyDown=FaceButtonRight) to progress through normal dialog and another button (the ‘confirm’ button) to click on dialog option buttons.
Looks like the solution involves releasing the button manually after every time it’s pressed? I don’t understand why having a ‘confirm’ button makes the FaceButtonBottom unusable for OnKeyDown. Sorry for my amateurish question. I wasn’t expecting a dialog box to be this overly complicatd.

(post deleted by author)