UMG Button and button logic in C++

Hi,

I apologize in advance if my explanation is confusing.

I’m trying to separate the visuals from the logic in UMG, a bit like MVC and MVVM design, but I can’t seem to be able to access buttons in C++. Here is pseudocode-ish

UClass() class XYZ : public UUserWidget { ....
   UPROPERTY(BlueprintReadWrite, Category = "Something")
   Button MyButton;

   FButtonStyle AButtonStyle;
   
   void SetHoveredButtonStyle() 
   {
      MyButtonStyle->WidgetStyle = AButtonStyle;
   }
}

So, in the end, the artist would just attach this base class to his widget, set the MyButton to his created button in the constructor script, and the logic in C++ would handle everything except the styling and layout.

Any idea on how I can do this?
I cannot find any class that I can compile AND give access to blueprint for the button
If you can explain to me a bit on how Button Styles work (how I can define them and how I can use them correctly) I would also be very appreciated but my biggest issue is the compiling problem :frowning:

You can use meta = (BindWidget) inside UPROPERTY, this will enforce the widget in BP to have a Button with same name as in C++ other wise BP will not compile.