What is the widget equivalent of an Actor Component / how to call C++ functions from a widget blueprint?

I’m making a drag-and-drop menu as a Widget Blueprint. I’ve been prototyping the simple stuff with blueprints, but I’ve got to the point where I’m going to need to work in C++. I’m not sure how to do this though.

When I’ve done this with Actors, I’ve done it by creating a AActorComponent C++ class and calling its functions from the Actor blueprint. However, widget blueprints don’t seem to have a WidgetComponent class. I basically want to make a c++ class with some helpful functions (e.g. an OnDrop function that checks where in the vertical box of children the user has dropped a widget and places it appropriately). What’s the correct way of doing this with widgets?

Is the answer that the C++ class needs to be added to the player controller? This doesn’t seem to fit with the hierarchy to me, as the C++ class is only interacting with the widget. Surely, it should belong to the widget?

It may be I’m doing this in completely the wrong way, just going on what I’ve done and been advised before when working with actors.

I’m not really sure either, but Player Controller is vital to widgets, as the Widget needs an Owner, and Unreal is designed around the idea that each Widget has to have a specific Player Controller be its owner. So that makes it easy to put all your widget controlling code in the Player Controller but I agree, it doesn’t seem like the best idea.