Cannot Disable UCanvasPanel

I’m trying to disable the CanvasPanel, and all its children. Unfortunately nothing seems to work.

From the Canvas C++ code, SetIsEnabled(false) does not work. Looping through all the widgets doesn’t seem to work:

TArray<UWidget*> widgets;
WidgetTree->GetAllWidgets(widgets);

for (int32 x = 0; x < widgets.Num(); ++x)
    widgets[x]->SetIsEnabled(enabled);

When I uncheck the Is Enabled for the CanvasPanel within the editor, and start my game, it works.

What am I doing wrong? Any suggestions?

The Code you got has a slight error you increasse “x” first basicly skipping the first item Change it to “x++” instead and it will work as you have it.

Alternativly you can do this =) it looks nicer

WidgetTree->ForEachWidget([&](UWidget* Widget) {
Widget->SetIsEnabled(false);
});

Thank you Nachtmahr, the ForEachWidget is a nice alternative.

I would like to point out that the above code does not miss the first element, as can be seen from a Visual Studio screenshot:

138459-prepostinc.jpg

Also, I would recommend a Internet search on Pre-Post Increment reasons. For example, here is one:

http://www.embedded.com/design/programming-languages-and-tools/4410601/Pre-increment-or-post-increment-in-C-C-

I tried it with:

Result:

Even if I PrintString the IsEnabled state of the Canvas it tels me false. Everything works as expected regardless if I start out with false or true.
Did you by any chance grabbed some SubTree?

Yes, you are right, it does work as expected.

The real problem was incorrectly thinking that I was displaying a model window and waiting for the response:

    SetIsEnabled(false);
    menuManager->ShowMenu(DeleteMenu, false);
    SetIsEnabled(true);