I created the standalone window plugin and now I am trying to add a button to the tab. I am confused on how to use the OnClicked function correctly. I want change the color to green if the button color is currently red and vice versa. the following code is:
TSharedRef FTaskManagerModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
// Put your tab content here!
SNew(SButton).ButtonColorAndOpacity(FLinearColor(1.0f, 0.0f, 0.0f, 1.0f)).OnClicked(/*not sure what to do here*/)
I’m not knowledgeable enough to be certain, but I don’t think you can override the functions of a native class in realtime (perhaps with Lambdas, but I’m not familiar enough with using them to say for certain).
My 2 cents, would be to do the following:
- Create your own child button Button
- Create an ENum for your desired
- Add a property to your custom button
class for the enum.
- Override the OnClicked event for
your custom button.
- Within the OnClicked event code, use
“switch” to determine the current
color selection and change the color
accordingly and update the current
Here’s a quick example:
Within your Custom Button UCLASS of the .h file
UPROPERTY(BlueprintReadOnly, Category = "YourCategory")
in your .cpp file within the overriden OnClicked Event…
// Additional code to change the button's color value to green
ButtonColor = EButtonColor::Green;
// Additional code to change the button's color value to red
ButtonColor = EButtonColor::Red;
The above isn’t verbatim, but should get you rolling if applicable.