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?
@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:
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:
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.