SComboButton not building

Hi,

I am in the process of building an interface for my game. I need to make a content picking system : click on a button and a panel pops up to shows you a list of available content.

I went to the SComboButton class (is this the right choice ?) but I am having trouble getting the code to build. Here is my work.

SNew(SComboButton)
.OnGetMenuContent(this, &SFlareMenu::GetTestContent)
.ButtonContent()
[
	SNew(STextBlock)
	.Text(FString("Combo box test"))
]

TSharedRef<SWidget> SFlareMenu::GetTestContent() const
{
	FMenuBuilder MenuBuilder(true, NULL);

	MenuBuilder.AddMenuEntry(
		TEXT("Key"),
		TEXT("Key tooltip"),
		FSlateIcon(),
		FUIAction(FExecuteAction::CreateSP(this, &SFlareMenu::VoidFunction))
		);

	return MenuBuilder.MakeWidget();
}

It is basically copy-pasted from UE’s source code. But it won’t build :

20>D:\UnrealEngine\Engine\Source\Runtime\Core\Public\Misc\Attribute.h(48):
error C2248: ‘FText::FText’ : cannot
access private member declared in
class ‘FText’ 20>
d:\unrealengine\engine\source\runtime\core\public\internationalization\Text.h(265)
: see declaration of ‘FText::FText’
20>
d:\unrealengine\engine\source\runtime\core\public\internationalization\Text.h(105)
: see declaration of ‘FText’ 20>
D:\Flare\Source\Flare\UI\Menus\FlareMenu.cpp(150)
: see reference to function template
instantiation
‘TAttribute::TAttribute wchar_t[4]>(OtherType (&))’ being
compiled 20> with 20>
[ 20> OtherType=const
wchar_t [4] 20> ] 20>
D:\Flare\Source\Flare\UI\Menus\FlareMenu.cpp(150)
: see reference to function template
instantiation
‘TAttribute::TAttribute wchar_t[4]>(OtherType (&))’ being
compiled 20> with 20>
[ 20> OtherType=const
wchar_t [4] 20> ] 20>
d:\unrealengine\engine\source\runtime\core\public\internationalization\Text.h(265)
: see declaration of ‘FText::FText’
20>
d:\unrealengine\engine\source\runtime\core\public\internationalization\Text.h(105)
: see declaration of ‘FText’

FlareMenu.cpp:150 refers to the last line of the AddMenuEntry() call (yes, the “;” line).

So what’s wrong with this code ?

Thanks !

So you’re passing Fstring parameters where Ftext should be. Try using FText::FromString(TEXT("")) instead of only Fstring or TEXT

Or even better, use LOCTEXT or NSLOCTEXT so that you could later localise the strings :slight_smile: