Why are all my Buttons of my HUD disabled and can't be activated?

I am troubleshooting my UI. I put some buttons and I bound functions to the OnClicked delegates. I am working with both, UButtons and MyCommonButton, which inherits from CommonButtonBase from the Common UI plugin.

The OnClicked events seemingly never fire, the bound functions never execute for both, my UButtons and my MyCommonButtons.

I managed to get the tooltip to show, by moving another UI element to the back (I gave the other element z-index -1).

I also activated the styling, such that a disabled button has a pink background color and there I saw it:

All my buttons are always in a disabled state (pink background) even though is Enabled is ticked true. I also tried to set

Button->bIsEnabled = true;

in BeginPlay.

The visibility of the buttons is set to Visible. I set all parents to Not hit-testable (self-only). This is how I add my HUD to the viewport in C++:

void AMyHUD::BeginPlay()
{
	Super::BeginPlay();

	const TObjectPtr<APlayerController> PC = GetOwningPlayerController();
	if(!PC)
	{
		UE_LOG(LogTemp, Warning, TEXT("%s: BeginPlay: no player controller, disabling tick"), *GetFullName())
		SetActorTickEnabled(false);
		return;
	}

	// set up HUD

	if(!WidgetHUDClass)
	{
		UE_LOG(LogSlate, Error, TEXT("%s: WidgetHUDClass null"), *GetFullName())
		return;
	}

	WidgetHUD = CreateWidget<UUserWidget>(PC.Get(), WidgetHUDClass);
	WidgetHUD->SetVisibility(ESlateVisibility::Visible);
	WidgetHUD->AddToViewport();

    // ...
}

So why does Unreal Engine somehow forces my button to be in a disabled state?

Hey @rubm123
Do any of the other events work?

I just checked:

OnHovered doesn’t fire. Maybe this isn’t a surprise, given that the buttons appear disabled.

Also: Setting the button to enabled via the BluePrint node Set Enabled in BeginPlay doesn’t change their disabled status, either.

@rubm123
The only other debugging I can think of is to use the IsInteractable function because I really can’t discern the problem anymore.
Is there any text covering the button at all? I’ve seen a few forum posts about the text making it impossible to click, but that doesn’t sound like your issue.
It could also be input routing, which I know is used by CommonUI to permit only certain widgets to receive input:

I hope this can help!
-Zen

1 Like

Thanks. I have the same problem with my UBottons - so it’s not specific to common UI.

After having worked for a while on my project, it’s just the first time to add a button (any button) to my HUD and they are disabled. ¯\_(ツ)_/¯

I might have to do the following:

  • start a new project from scratch
  • add HUD with button: it works! (it isn’t disabled)
  • re-implement my HUD in this new project, step by step until the button ceases to work (appears to be disabled for no reason)

I am hesitant, though. It might as well happen that I recreate my HUD and the problem never occurs there.

It could also be input routing, which I know is used by CommonUI to permit only certain widgets to receive input

“Common UI routes inputs to whatever UI widget is visually rendered on top.”

This sounds like the most plausible cause for my troubles so far … I will investigate further.

EDIT: upon further testing, I couldn’t confirm the glitch below. Rather it seems that I had put Is Enabled to false for some parent widgets. And IsEnabled = false disables all child widgets quite strictly, it seems.


ORIGINAL POST:

I found the error and I blaim a glitch in the Unreal Engine.

Following advice from my girlfriend, I moved buttons around in my UMG Widget hierarchy that looks like this:

image

Finally, the solution to the deactivated buttons:

Once I replace the retainer box by deleting it and putting it there, again my buttons (both, UButton and MyCommonButton) unfroze from their forcefully disabled state.

In theory, there could be a setting of the retainer box that I basically reset by deleting it. But I can’t find a setting that reproduces the forcefully disabling of buttons inside it.

This is why I think it’s a glitch.

2 Likes

@rubm123 Sweet - I’m glad you got it resolved though and posted the solution!
Happy Developing!
-Zen

2 Likes