UMG: UButton->SetIsEnabled(false); disables all of UMG

Hello,

Disabling a single button in C++ disables all UMG button functionality. When this happens, all buttons will become disabled at once, and the mouse can’t even click the minimize/maximize/close in the PIE window.

Note: Not sure if it matters, but I’ve got my button in a UUserWidget which is inside a UHorizontalBox (MenuBar), and it’s being called like so:

MenuBar->GetChildAt(0))->Button->SetIsEnabled(false);

Everything else works perfectly, but attempting to disable any button will disable everything.
I assume these problems would also happen on regular buttons on the canvas without the wrapper.

Is there any workaround for this?

Thanks

Edit:
I used it on the construction of a button and it seems to work there, so it may only break UMG when used after clicking the button through OnPressed

Hey -

How exactly are you setting up your UMG in code? When tested in blueprint, disabling one button did not affect other buttons (the disabled button grayed out but other buttons did not and could still be clicked). If possible, please provide your setup or a small sample project showing the issue to help investigate locally.

Hi ,
My slow computer takes waaay too long to make a new project, considering VS then needs to parse the engine code, etc. So since the code is simple, I will just provide that for now.

  1. Create a class that extends UserWidget, this will house the button and handle it’s click code.

    UCLASS()
    class MYPROJECT_API UHudButton : public UUserWidget{
    	GENERATED_BODY()
    public:
    	virtual void NativeConstruct();
    	UFUNCTION() void OnButtonClick();
    	UPROPERTY() UButton* Button;
    };
    
  2. Grab the button object from the widget blueprint, and set it to disable itself when pressed.

    void UHudButton::NativeConstruct()
    {
    Super::NativeConstruct();

    Button = Cast<UButton>(GetWidgetFromName(TEXT("BP_Button")));
    Button->OnPressed.AddDynamic(this, &UHudButton::OnButtonClick);
    

    }

    void UHudButton::OnButtonClick()
    {
    Button->SetIsEnabled(false);
    }

  3. Create a blueprint child of that class, and add a button with the name BP_Button, so it can be accessed from the construction function.

  4. Place a bunch of those buttons and click one of them. Rather than it disabling itself, all of UMG should freeze up, including the PIE window controls.

Edit: Sorry the post seems to be autoformatting, messing up my step numbers and forcing some of my code into regular text.

Thank you for the code. I have reproduced this issue and logged a report for it here Unreal Engine Issues and Bug Tracker (UE-42777) . 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