Get Widget Class From Widget Component?

I have a tag that tells what an item is. The tag floats over the item. The tag is a Widget Component to the item actor. The Widget Component has its widget class set as a basic tag. Instead of making a new tag widget for each item, I want to reference a variable inside the item that says what item it is, and use that to power a binding within the widget to display the proper item name. In order to do this, though, I need to send info from the actor to the widget. And in order to do that, I need a reference to the widget.

Basically, I want to know how to get a reference to the widget class of a Widget Component from that Widget Component, so I can send data from an actor to the widget of that Widget Component’s widget class.

Thanks.

(Also “widget” doesn’t sound like a word anymore after reading this out loud :P)

That is pretty straight forward:

UYourWidgetClass* widgetObject = Cast(YourWidgetComponent->GetUserWidgetObject());

Cheers, .

Maybe you would elaborate please, how to set up this blueprint? I encountered same problem, I’m making a keypad and I need the keypad item to send the defined code to the widget instance.

For anyone who finds this is the future and is confused, check out the answer posted here


Like this, where Bubble is the Widget Component and WBP_ThoughtBubble is the Widget Blueprint class.

3 Likes