Hi guys,
I’m new to Slate, could you help me why my Buttons are not working?
After a few hours of trial and error I’m kinda frustrated.
Thanks in advance!
Note: The Buttons start after the //Lower Row comment.
I showed the whole thing because I think there’s some overlap with the earlier slate widgets.
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SMainMenuUI::Construct(const FArguments& InArgs)
{
MainHUD = InArgs._MainHUD;
ChildSlot
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(FMargin(0))
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Red)
.Padding(FMargin(15))
.Content()
[
SNew(SVerticalBox)
// Upper Row
+ SVerticalBox::Slot()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Blue)
.Content()
[
SNew(STextBlock)
.ColorAndOpacity(FLinearColor::White)
.ShadowColorAndOpacity(FLinearColor::Black)
.ShadowOffset(FIntPoint(-1, 1))
.Font(FSlateFontInfo("Arial", 26))
.Text(FText::FromString("Numbers Stuff"))
]
]
+ SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Yellow)
.Content()
[
SNew(STextBlock)
.ColorAndOpacity(FLinearColor::White)
.ShadowColorAndOpacity(FLinearColor::Black)
.ShadowOffset(FIntPoint(-1, 1))
.Font(FSlateFontInfo("Arial", 26))
.Text(FText::FromString("Money"))
]
]
+ SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Yellow)
.Content()
[
SNew(STextBlock)
.ColorAndOpacity(FLinearColor::White)
.ShadowColorAndOpacity(FLinearColor::Black)
.ShadowOffset(FIntPoint(-1, 1))
.Font(FSlateFontInfo("Arial", 26))
.Text(FText::FromString("People"))
]
]
+ SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Yellow)
.Content()
[
SNew(STextBlock)
.ColorAndOpacity(FLinearColor::White)
.ShadowColorAndOpacity(FLinearColor::Black)
.ShadowOffset(FIntPoint(-1, 1))
.Font(FSlateFontInfo("Arial", 26))
.Text(FText::FromString("Power"))
]
]
]
]
// Lower Row
+ SVerticalBox::Slot()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Blue)
.Content()
[
SNew(STextBlock)
.ColorAndOpacity(FLinearColor::White)
.ShadowColorAndOpacity(FLinearColor::Black)
.ShadowOffset(FIntPoint(-1, 1))
.Font(FSlateFontInfo("Arial", 26))
.Text(FText::FromString("Button Stuff"))
]
]
+ SHorizontalBox::Slot()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Yellow)
.Content()
[
SNew(SButton)
.Text(FText::FromString("Money Stuff"))
.DesiredSizeScale(FVector2D(2.5, 2.5))
.OnClicked(this, &SMainMenuUI::PlayGameClicked)
]
]
+ SHorizontalBox::Slot()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Yellow)
.Content()
[
SNew(SButton)
.Text(FText::FromString("People Stuff"))
.DesiredSizeScale(FVector2D(2.5, 2.5))
.OnClicked(this, &SMainMenuUI::QuitGameClicked)
]
]
+ SHorizontalBox::Slot()
[
SNew(SBorder)
.BorderBackgroundColor(FLinearColor::Yellow)
.Content()
[
SNew(SButton)
.Text(FText::FromString("Power Stuff"))
.DesiredSizeScale(FVector2D(2.5, 2.5))
.OnClicked(this, &SMainMenuUI::TestButtonClicked)
]
]
]
]
]
];
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
All of the functions are like this:
FReply SMainMenuUI::PlayGameClicked()
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Blue, TEXT("Play Game Clicked"));
}
return FReply::Handled();
}
Yet there’s no output. Anyone with Slate knowledge seeing some obvious mistake?
What it looks like in PIE:
http://i.imgur.com/PT7t3cv.png
I used the borders to see if there’s obvious overlap, but I guess I used them wrong.
Thanks for your time and help!