x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Bind UFunction to Widget Event with Input Variable on Runtime ue4 c++?

Hello Friends,

I'm currently trying to bind a UFunction to a UImage that I create on runtime. I would like to bind an aactor to the UImage input function, but cannot figure out how to pass that reference on runtime...

Does anyone know how to append an object reference to .BindUFunction? Subsequently, I think I could work around this if I knew how to get the name of the widget that was clicked from c++.

Thank you for your time!

Here's my current code:

 void MyClass::CreateBlips() {
         int i = 0;
         for (AActor* Actor: AllActors) {
             UImage *newBlip= DuplicateObject<UImage>(originalBlip, this, FName(TEXT("%d"),i));
     
             newBlip->OnMouseButtonDownEvent.BindUFunction(this, FName("BlipMouseDown"));
            i++
         }
     }
     
     FEventReply MyClass::BlipMouseDown(FGeometry geo, const FPointerEvent& fevent, AActor* MyActor)
     {
         //get according actor referenced to clicked uImage
         UE_LOG(LogTemp, Warning, TEXT("Actor corresponding to blip is %s"), *MyActor->GetName());
 
         return FEventReply(false);
     }

Product Version: UE 4.22
Tags:
more ▼

asked Apr 16 '19 at 04:29 PM in C++ Programming

avatar image

anoxxi-dis
6 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

OnMouseButtonDownEvent has so few data, I would make a child class with :

a public weak pointer to an actor

and new "OnClicked" event that pass the newImage object (this) as arg

this class would subscribe to it's own "OnMouseButtonDownEvent" and broadcast the new event from here with the data

more ▼

answered Apr 17 '19 at 04:41 PM

avatar image

Firefly74
1.4k 14 17 31

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question