Skip to content

Lambda as parameter

Unreal Lambda Type

Like this: TFunction<returntype(param1, param2, ...)> ParameterName

cpp
void MyFunction(TFunction<void()> LambdaParam)
{}

void MyFunctionWithParams(TFunction<void(FText, bool)> LambdaParam)
{}

Example Of usage

cpp
TSharedRef<SButton> EditoolsUE4::EditoolsButton::CreateButton_Lambda(TFunction<FReply()> LambdaEventOnClick, FText TextButton, FText TooltipTextButton, FLinearColor ButtonColor, FLinearColor TextColor)
{
	return SNew(SButton)
		.OnClicked_Lambda(LambdaEventOnClick)
		.ToolTipText(TooltipTextButton)
		.ButtonColorAndOpacity(FSlateColor(ButtonColor))
		[
			SNew(STextBlock)
			.Text(TextButton)
		    .ToolTipText(TooltipTextButton)
		    .ColorAndOpacity(FSlateColor(TextColor))
		];
}