Case:
On UserWidget::PreConstruct you want to do UInputKeySelector::SetTextBlockVisibility on an inner widget. It can fail silently:
void UInputKeySelector::SetTextBlockVisibility(const ESlateVisibility InVisibility)
{
if (MyInputKeySelector.IsValid())
{
EVisibility SlateVisibility = UWidget::ConvertSerializedVisibilityToRuntime(InVisibility);
MyInputKeySelector->SetTextBlockVisibility(SlateVisibility);
}
}
Case:
You want to set a few style properties in c++ on the widget.
SetButtonStyle(&DTPtr->WidgetStyle);
TextStyle = DTPtr->TextStyle;
Margin = DTPtr->Margin;
Well ■■■■! there is no setter for one or more properties as usual, so the widget won’t synchronize to slate automatically.
SynchronizeProperties();
Well ■■■■ again, because the synchronization method doesn’t check if it has been build yet, resulting in a crash (as usual with these slate frankensteins)
void UInputKeySelector::SynchronizeProperties()
{
Super::SynchronizeProperties();
MyInputKeySelector->SetSelectedKey( SelectedKey );
MyInputKeySelector->SetMargin( Margin );
MyInputKeySelector->SetButtonStyle( &WidgetStyle );
Well… Then we build it ourselves? Well ■■■■, if we do so the widget loses certain properties we set which haven’t been safely stored anywhere besides in the widget we just dump and rebuild, such as… The text block visibility.
TSharedRef<SWidget> UInputKeySelector::RebuildWidget()
{
MyInputKeySelector = SNew(SInputKeySelector)
.SelectedKey(SelectedKey)
.Margin(Margin)
.ButtonStyle(&WidgetStyle)
.TextStyle(&TextStyle)
.KeySelectionText(KeySelectionText)
.NoKeySpecifiedText(NoKeySpecifiedText)
.AllowModifierKeys(bAllowModifierKeys)
.AllowGamepadKeys(bAllowGamepadKeys)
.EscapeKeys(EscapeKeys)
.OnKeySelected( BIND_UOBJECT_DELEGATE( SInputKeySelector::FOnKeySelected, HandleKeySelected ) )
.OnIsSelectingKeyChanged( BIND_UOBJECT_DELEGATE( SInputKeySelector::FOnIsSelectingKeyChanged, HandleIsSelectingKeyChanged ) );
return MyInputKeySelector.ToSharedRef();
}
You guys sure know how to mess up.
Add this to the list of my bug reports, I get 0 response from staff on Slate / UMG reports anyway. Unbelievable. You need to be able to set the visibility of the text widget if you simply want to swap between the input key name and a gamepad icon without the text. If we are supposed to actually use the provided Slate (slate / umg frankenstein) then at least make it work. I want to support this framework and not reinvent the wheel, but I’m not OK with the ■■■■ you ship with UE5.