0

I have a UMG blueprint (let it be A) that simply inherits from User Widget (No custom C++ subclass). It resides in another UWidget (name it B) (but inherited from custom C++ subclass).

My first question is what’s the best practice to get a pointer to A from B. I’ve currently bounded its UPROPERTY (UPROPERTY(meta=(BindWidget))).

Secondly, How can I assign a C++ function to the OnClicked event of A from B (without decorators).

A_Kz
  • 139
  • 1
  • 8
  • 1
    I am not sure I am 100% getting what you are asking, correct me please: So there is `B`, a `UserWidget` that inherits from a custom `UserWidget` C++ class and `A`, a widget that is just a plain `UserWidget`. `A` is a component of `B`. You want to transfer data from `A` to `B` and react to an event from `B` in `A`? I see two options here: Either transfer the data via blueprint nodes or create a subclass of `UserWidget` for `A` to inherit from that has the `OnClicked` event and the setter that you want to use to "get a pointer from A to B". I see no other (reasonable) options here. – Max Play Jul 08 '23 at 15:37
  • Thanks. You're totally correct. I eventualy did same as you mentioned. I was wondering if there's any other way to manipulate plain UserWidgets. There exist methods that can add functions to BPs or replace their underlying UFunctions. But didn't seem to be good practices. – A_Kz Jul 08 '23 at 16:44
  • 1
    My advice here is (and SO is not an advice-platform outside of its comments): Do not mix Blueprint and non-Blueprint code. Do not try to manipulate the code via reflection. If you want a method to be callable, make a base class with `UFUNCTION(BlueprintCallable)` and call that via C++. Never try to call custom events from C++, there are ways to get them called, e.g. via delegates. – Max Play Jul 09 '23 at 09:53
  • Sure, Thanks for the advice – A_Kz Jul 09 '23 at 10:36

0 Answers0