I have a plugin on the marketplace, and part of its logic is automatically calling the OnPressed and OnClicked events of certain buttons at a certain time (other than when the player clicks those buttons). The plugin has a custom button class, called UINavButton, which inherits from Button and listens to the button events (OnPressed, OnClicked, etc.)
I’m trying to broadcast the button events manually by accessing said button’s OnPressed property and then calling Broadcast, like in this code snippet:
CurrentButton->OnPressed.Broadcast();
However, when I do this, the button’s OnClicked event is broadcast instead!
This is the code inside UINavButton that listens to the button events:
UUINavButton::UUINavButton()
{
IsFocusable = false;
OnHovered.AddDynamic(this, &UUINavButton::OnHover);
OnUnhovered.AddDynamic(this, &UUINavButton::OnUnhover);
OnClicked.AddDynamic(this, &UUINavButton::OnClick);
OnPressed.AddDynamic(this, &UUINavButton::OnPress);
OnReleased.AddDynamic(this, &UUINavButton::OnRelease);
}
Here are the OnPress and OnClick functions:
void UUINavButton::OnClick()
{
CustomClick.Broadcast(ButtonIndex);
}
void UUINavButton::OnPress()
{
CustomPress.Broadcast(ButtonIndex);
}
Note: CustomClick and CustomPress are delegates that I made, and they work just fine.
The problem is, when I broadcast the UINavButton’s OnPressed event, like shown in the first code snippet, the OnClick function is called instead of the OnPress function, which to me doesn’t make any sense…
It’s worth noting that I can’t reproduce this consistently! Some menus that contain these buttons will have the OnPress event being broadcast correctly, while others won’t.
Am i missing something, or is this a bug?
Thanks for your attention in advance 