How to access SButton from inside of OnClicked_Static(...)?

Hello.

Inside of my FMyPluginEdModeToolkit::FMyPluginEdModeToolkit(){...}, reacting to button click I would like to disable the “left” button. But how to call that “left” button from inside of OnButtonClick(...)?

The code is based on sample plugin:

MyPluginEdModeToolkit::FMyPluginEdModeToolkit()

	struct Locals{
		static FReply OnButtonClick(FVector InOffset){
			//how do disable the "left" button here?
			return FReply::Handled();
		}

		static TSharedRef<SWidget> MakeButton(FText InLabel, const FVector InOffset){
			return SNew(SButton).Text(InLabel).OnClicked_Static(&Locals::OnButtonClick, InOffset);
		}

	};

	const float Factor = 256.0f;

	SAssignNew(ToolkitWidget, SBorder).HAlign(HAlign_Center).Padding(25)
	.IsEnabled_Static(&Locals::IsWidgetEnabled)
	[
		SNew(SVerticalBox)
		+SVerticalBox::Slot()
		.AutoHeight().HAlign(HAlign_Center).Padding(50)
		[
			SNew(STextBlock)
			.AutoWrapText(true)
			.Text(LOCTEXT("HelperLabel", "Plugin description."))
		]

		+SVerticalBox::Slot()
		.HAlign(HAlign_Center).AutoHeight()
		[
			Locals::MakeButton(LOCTEXT("UpButtonLabel", "Up"), FVector(0, 0, Factor))
		]
		+SVerticalBox::Slot()
		.HAlign(HAlign_Center).AutoHeight()
		[
			SNew(SHorizontalBox)
			+SHorizontalBox::Slot().AutoWidth()
			[
				Locals::MakeButton(LOCTEXT("LeftButtonLabel", "Left"), FVector(0, -Factor, 0))
			]
			+SHorizontalBox::Slot().AutoWidth()
			[
				Locals::MakeButton(LOCTEXT("RightButtonLabel", "Right"), FVector(0, Factor, 0))
			]
		]
	];

Hi there ; )

You cant do that unless you pass a pointer to a button as a function parameter OR (a better solution) dont make OnButtonClick static, make it a member of MyPluginEdModeToolkit and store the pointer to your “left” button like this:

MyLeftButton =  Locals::MakeButton(LOCTEXT("LeftButtonLabel", "Left"), FVector(0, -Factor, 0));

then, in OnButtonClick you can will be able to access MyLeftButton pointer.