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"

Object is bound to delegate, before binding is executed in code.

Hi. I've created a class deriving from UHorizontalBox, it is a custom class that helps with gamepad navigation. I have a strange problem with delegate binding. In the OnWidgetRebuilt function, I'm binding functions to delegates in HorizontalBox's children - which are custom buttons(OnHover, OnClick, etc.). The problem is that before the OnWidgetRebuilt function is executed there is already appropriate function bound to that delegate(don't know why) and sometimes even there are bindings that don't exist in code anymore. For example, when I created binding to OnUnhovered and later on decided to remove it, it is still somehow bound to that function. I have tried executing this code not only in OnWidgetRebuilt, but also RebuildWidget and PostLoad, with no results, rebuilding project doesn't help either.

I've tried to debug it with breakpoints and RebuildWidget happens only once, I even protected it with a bool check just to be sure. The only thing that helped was to clear binding list from that delegate and then bind my functions to it, but that doesn't solve my problem because then I can't bind anything to buttons in my widget's construct function. On top of that there is a huge freeze in-game when any widget with my custom class is shown, during the freeze it gives my this error message:


error points to line 60 in db_interactivehorizontalbox.cpp :

Btn->OnButtonClicked.AddDynamic(this, &UDB_InteractiveHorizontalBox::SelectButtonByRef);

It didn't freeze and it didn't give me an error when whole binding logic was in PostLoad, but problems with binding existed anyway.

whole function:

 void UDB_InteractiveHorizontalBox::OnWidgetRebuilt()
     if (bInitOnStart && !bInit && !IsDesignTime())
         bInit = true;
         for (int i = 0; i < GetChildrenCount(); i++)
             auto* Btn = GetButtonAtIndex(i);
             if (Btn)
                 if (PanelWidgetType == EDB_PanelWidgetType::SelectOnHover)
                     Btn->OnButtonHovered.AddDynamic(this, &UDB_InteractiveHorizontalBox::SelectButtonByRef);
                 else if (PanelWidgetType != EDB_PanelWidgetType::MultiSelect && PanelWidgetType != EDB_PanelWidgetType::LockOnSelect)
                     Btn->OnButtonHovered.AddDynamic(this, &UDB_InteractiveHorizontalBox::HighlightButtonByRef);
                 Btn->OnButtonClicked.AddDynamic(this, &UDB_InteractiveHorizontalBox::SelectButtonByRef);
         if (PanelWidgetType == EDB_PanelWidgetType::Standard || PanelWidgetType == EDB_PanelWidgetType::SelectOnHover)

Because all the functions that I mentioned are happening not only in game time, but also design time, is it possible that these delegates start with something bound to them?

I'm probably missing something obvious, but I don't know how to move on, as I've been trying to solve that for hours. If anyone could help, I would be very glad.

alt text

Product Version: UE 4.19
more ▼

asked Nov 20 '18 at 08:30 AM in C++ Programming

avatar image

King Zero
25 1 5

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

0 answers: sort voted first
Be the first one to answer this question
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