BlueprintImplementableEvent Bug?

I have a declaration in the parent class to a UMG blueprint:

UFUNCTION(BlueprintImplementableEvent, Category = MainMenu)
void AddKeybindEntry(FString Title, FString Key);

The two parameters (Title, Key) are supposed to be input parameters to the UMG function. However, they are showing up as output parameters in UMG when I try to implement the function. Am I misunderstanding something or is this a bug?

Is this your code as-is? I’m surprised it even compiles.

A preamble: You should never pass FStrings by value as this causes them to get copied needlessly each time you pass them around. You should instead be passing them by reference:

UFUNCTION(BlueprintImplementableEvent, Category = MainMenu)
void AddKeybindEntry(const FString& Title, const FString& Key);

By passing a reference, you avoid unnecessarily creating a copy of the string each time it is passed around. By further making this reference const, you state the intent that these are inputs and as such should never be modified, which would have unfortunate side effects.

For blueprints, the header generator actually enforces this to an extent and the autogenerated thunk for the blueprint event converts the FString parametres to FString&s, which in turn causes a compile error on my end.

I don’t know which version of UE you’re running, but I’m guessing it has different behaviour and silently generates the following thunk:

void UMyWidget::AddKeybindEntry(FString& Title, FString& Key)

The blueprint compiler treats non-const reference parametres as output params, this is basically how you create functions with multiple outputs.

To clarify, here’s two different ways of declaring that function, and the blueprint nodes they generate:

UFUNCTION(BlueprintImplementableEvent, Category = MainMenu)
void AddKeybindEntry( FString& Title, FString& Key );


UFUNCTION(BlueprintImplementableEvent, Category = MainMenu)
void AddKeybindEntryConst( const FString& Title, const FString& Key );


The second is likely what you want.

In case the red AddKeybindEntryConst event node doesn’t make it obvious, do note that Blueprint events that have no output values don’t show up as implementable functions, but instead show up as an event to use in your event graph. I forgot about this when creating blueprint implementable events for my UMG widgets and was wondering why the hell they wouldn’t show. :slight_smile:


Actually, I did try it by passing a const reference and I got the same result. But I think that was a carry-over from the first attempt. I have since changed the code so that it doesn’t pass the string at all.

Perfect Thanks!