Delegates with Slate

I’m having a bit of trouble of hooking up a delegate to my Slate instance and I’m wondering how it should be done, does anyone have any suggestions. I’m a beginner when it comes to programming so forgive me if this seems obvious.


	

				[SNew(STextBlock).Visibility(EVisibility::Visible)
				.ShadowColorAndOpacity(FLinearColor::Black)
				.ColorAndOpacity(FLinearColor::White)
				.ShadowOffset(FIntPoint(-1, 1))
				.Font(FSlateFontInfo("Verdana", 20))
				.Text(FText::FromString(talk[obj.counter]))
				.WrapTextAt(float(TextIn = 1000))
				.OnDoubleClicked(FOnClicked(one.Execute)) //part that doesn't work

				]

			]


I have a short writeup here on using Slate attributes and delegates. The jist of it is the syntax can be kind of finnicky depending on where you’re binding a delegate.

Thankfully, the declarative syntax (which is what you’re using in this case) is the most forgiving. You can nose around DeclarativeSyntaxSupport.h to see what’s supported. Now, OnDoubleClicked uses the FOnClicked signature: DECLARE_DELEGATE_RetVal( FReply, FOnClicked ). So you’ll need a function with no params and a single FReply return value. Say you name that function OnDoubleClickedHandler, binding it should be as simple as:


SNew(STextBlock)
.OnDoubleClicked( this, &SMyWidget::OnDoubleClickedHandler )

Got it working mate, thanks a lot! I’ve managed to see whats supported in the syntax as well :slight_smile: