Working with slate

Hello dev, Hope you’re all well. I just started out experimenting with creating plugins and slate. I guess I got the basic understanding of it. But well right now I am having a small problem. For the plugin creating a button, and its giving error of AsShared is not a member. I checked for solution online which said to use “OnClicked_Raw” is of “On Clicked” or call “CreateRaw” inside “OnClicked()”. Ive tried both and none of these works. Ill share the code here. I need solution for this. Hope to get help -fingers crossed-

//Cpp file

TSharedRef<SDockTab> FImageComparator_ESWModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
{
	FText WidgetText = FText::Format(
		LOCTEXT("WindowWidgetText", "Add code to {0} in {1} to override this window's contents"),
		FText::FromString(TEXT("FImageComparator_ESWModule::OnSpawnPluginTab")),
		FText::FromString(TEXT("ImageComparator_ESW.cpp"))
		);
	FString PathToImage;

	PathToImage = TEXT("default_pictures/HighresScreenshot00000.png");

	FString ImagePath = FPaths::GameContentDir() / PathToImage;
	FName BrushName = FName(*ImagePath);



	return SNew(SDockTab)
		.TabRole(ETabRole::NomadTab)
		[

			// Put your tab content here!
			SNew(SBorder)
			.HAlign(HAlign_Center)
			.VAlign(VAlign_Center)
			[
				SNew(SHorizontalBox)
					+SHorizontalBox::Slot() .HAlign(HAlign_Fill) .VAlign(VAlign_Fill)
						[
							SNew(SImage)
							.Image(new FSlateImageBrush(BrushName, FVector2D(1920, 1080)))
						]
					+SHorizontalBox::Slot() .HAlign(HAlign_Right) .VAlign(VAlign_Bottom)
						[
							SNew(SVerticalBox)
								+SVerticalBox::Slot() .HAlign(HAlign_Fill) .VAlign(VAlign_Fill)
									[
										SNew(SButton)
										.ButtonStyle(FEditorStyle::Get(), "FlatButton")
										.ForegroundColor(FLinearColor::White)
										.Text(LOCTEXT("PaperExtractSpritesCancelButton", "Cancel"))
										.OnClicked_Raw(this, &FImageComparator_ESWModule::ButtonClicked_custom)
									]
						]
		

			]
		];
}


FReply FImageComparator_ESWModule::ButtonClicked_custom()
{
	return FReply::Handled();
}

Your code seems ok to me. Is it giving you an error or is it just not working? I would recommend at least UE_LOG inside the ButtonClicked_custom. If it’s giving you an error, could you post the whole error? Also, you can try OnClick_Static with a static function.

This is very confusing for developers. In general, Unreal is confusing and having to read code from the engine to understand stuff is really bad.

OnClicked is the only function documented on SButton or similar. Where is that OnClicked_Raw? It doesn’t exist in the documentation. I’m trying to fix a bug here and I don’t know where this method comes from