SetNavigationRule does not ResolveExplicitRules

When calling SetNavigationRule on a User Widget at runtime after the user widget is constructed and setting a navigation rule to Explicit and providing a widget name, the navigation data for that widget is never fully updated as ResolveExplicitRules does not get called and thus there is no explicit widget reference to navigate to.

This makes it impossible to set explicit navigation rules at runtime as the only time ResolveExplicitRules is called is during the construction or template initialization of a widget.

Hey Allar-

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here Unreal Engine Issues and Bug Tracker (UE-50270) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

Doug Wilson

Issue still exists in 4.19.1 Git head 08339b73942f97764afceebdac78fadc117257a6

I stepped through “UWidget::SetNavigationRule()” and ended up in “UWidgetNavigation::UpdateMetaDataEntry()” → “case EUINavigationRule::Explicit:” → “if ( NavData.Widget.IsValid() )” which is always false.

A “UWidget::SetNavigationExplicit()” method similar to the “FNavigationMetaData::SetNavigationExplicit()” method would do the trick. Since I need this feature as well I wrote the following function inside our codebase basing on codes I saw while stepping through “UWidget::SetNavigationRule()”.

void SetNavigationExplicit(UWidget& InWidget, EUINavigation InNavigation, UWidget& InFocusRecipient)
{
	TSharedPtr<SWidget> SafeWidget = InWidget.GetCachedWidget();
	if (SafeWidget.IsValid())
	{
		TSharedPtr<FNavigationMetaData> MetaData = SafeWidget->GetMetaData<FNavigationMetaData>();
		if (!MetaData.IsValid())
		{
			MetaData = MakeShared<FNavigationMetaData>();
			SafeWidget->AddMetadata(MetaData.ToSharedRef());
		}
		MetaData->SetNavigationExplicit(InNavigation, InFocusRecipient.GetCachedWidget());
	}
}

Confirming that this bug is present in 4.20.02.

Unfortunately, I currently can’t find another way to get UMG navigation to properly ignore disabled widgets without going back to a fully custom, BP driven menu navigation system. Overall, there’s a number of these type of issues in UMG, such as navigation failing to skip over a disabled and non-focusable widget.

So this bug is still unresolved a year and a half later? Will this ever get fixed?

me too, the same problem

This has now been fixed internally and will be released in 4.24

SetNavigationRule has been deprecated.

4 new methods, which will handle all the cases, have been added:

  • SetNavigationRuleBase
  • SetNavigationRuleExplicit
  • SetNavigationRuleCustom
  • SetNavigationRuleCustomBoundary

Thanks Ferraro!