I was wondering how Widget Switchers work

Hi there,

I was wondering how widget switchers work when creating menus. From what I gather, can I use widget switchers as sort of sub-categories?

For example, I have an “Options” menu widget. Inside this widget, does a widget switcher allow me to sort “Video Settings”, “Audio Settings”, “Gameplay Settings”, etc into switchable tabs?

If so, how do I go about creating this? I tried messing around in the widget editor to no avail and searched online/forums but couldn’t find anything that explained it well enough.

Any help would be greatly appreciated. Thanks in advance!

-Raz

2 Likes

Thinking that myself

Finally got around to spending more with it. Can’t believe how simple it is actually.

For those interested, just create a Widget Switcher into UMG and add child widgets to the Hierarchy panel. The child widgets are separate UMG widgets you create, and can be found in the Palette panel under “User Created”. Click and drag those widgets you want to be able to switch to under the parent (as a child) of the Widget Switcher.

Each child is a widget index, starting with “0”. You need to then create buttons outside the widget component to enable switching. These buttons are the tabs that you switch between widgets with. Create as many buttons as you need and in the UMG graph, create OnClick events create Set Active Widget Index nodes for each button OnClick event. Don’t forget to reference the widget switcher as the target for each. That’s it!

Hope this helps someone :slight_smile:

5 Likes

Great that you got this sorted out… maybe you found this also…

How to trigger a widget switch from a button located WITHIN one of the widgets displayed by the widget switcher? I have been calling external calls to widget properties through an actor parent class. Works well with all properties except the widget switcher?

That may be as clear as mud, but as summed-up as I I could.

Thanks

Hi! This post has helped alot :slight_smile:
One thing that i’m wondering about tho… is that when the childed widget within the widget switcher is displayed, it only displays sections of the spesific widget, not the whole thing.
Is there a way to make the widget switcher display everything that’s within the child widget?

Could be that I haven’t looked and tried enough to make it be like I want to, but some help would be great! :slight_smile:

Thanks in advance!

Crossbones93, have you tried childing a panel or any other container to a switcher’s index, and then childing diifferent things to that single container?

Anyone have any information on how to do this in C++. Do we create an array of UWidgets specifying each one we want then overrride some buttons with OnButtonClicked() to carry out the functionality. And how do we actually switch in C++ from one widget to the other. Super easy in bp to do this but UWidgetSwitcher() in UE5 docs is rather lacking… no example code?

Answering my own question here…

if it helps anyone else…

It is actually as easy as it is in BP…
Create an int32 index and use this for your widget switcher nums
Set listeners on your buttons in the NativeConstruct() e.g Button->OnClicked.AddDynamic(this, &class::yourmethod)
and simply use on your SwitcherWidget->SetActiveWidgetIndex(index) to set the widget you want to show in the method…

PasteBin of code