Download

How to change editor button text

Currently I have a toolbox in the editor that has multiple tools in it which perform different functions. The toolbox has a button that you press to perform the function based on which tool you are using. Right now, I have the button set up like so:


SAssignNew(CurrentButton, SButton)
.Text(LOCTEXT("Editor", "Create Content"))
.OnClicked(this, &EditorToolbar::OnEditorClicked)
.IsEnabled_Lambda([this]() -> bool { return this->ToolsRegistered[CurrentlyTool]->CanRunTool(); })

and then when I want to change the text of the button when I switch to the other tool, I create a whole new button like so:


CurrentButton = SNew(SButton)
.Text(LOCTEXT("Editor", "Generate Images"))
.OnClicked(this, &EditorToolbar::OnEditorClicked)
.IsEnabled_Lambda([this]() -> bool { return this->ToolsRegistered[CurrentlyTool]->CanRunTool(); })

Is there a way to change the text of the button without creating a new button every time the user switches tools? I tried using CurrentButton->SetAttribute() but I’m not sure how to use it. CurrentButton is a TSharedPtr<SButton> btw.

Thanks!