I’m attempting to make a custom property layout for a struct. Among other things, I’d like to put multiple bool properties onto a single line. I’m attempting to do so by adding a custom row whose value content is a horizontal box. This box contains several slots that alternate between a text block label and a property value widget.
This works fine, but it’s a little bit difficult to read in the details panel because spacing is weird. So I decided to add a bit of padding to all of my horizontal box slots. And suddenly the text block labels no longer show up, and the property detail widgets no longer update the property!
Is there something that I don’t understand about how to properly Padding
on a horizontal box slot? How do you adjust the spacing of horizontal box slots without interfering with their content?
I’ve included a stripped down example that reproduces this behavior below. This code produces the attached screenshot. The only difference between the first row and the second is that the latter specifies Padding
on each of the horizontal box slots. The result is that in the second row:
- The text block labels don’t appear
- Clicking the checkboxes does not update the value of the underlying property (although the checkboxes in the second row do update if I change the value of the property via the first row)
Thanks for any help!
TSharedPtr<IPropertyHandle> prop1 = ...;
TSharedPtr<IPropertyHandle> prop2 = ...;
ChildBuilder.AddCustomRow(LOCTEXT("No Padding", "No Padding"))
.NameContent()
[
SNew(STextBlock).Text(LOCTEXT("No Padding", "No Padding"))
]
.ValueContent()
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot() [ SNew(STextBlock).Text(LOCTEXT("Foo", "Foo")) ]
+SHorizontalBox::Slot() [ prop1->CreatePropertyValueWidget() ]
+SHorizontalBox::Slot() [ SNew(STextBlock).Text(LOCTEXT("Bar", "Bar")) ]
+SHorizontalBox::Slot() [ prop2->CreatePropertyValueWidget() ]
];
ChildBuilder.AddCustomRow(LOCTEXT("With Padding", "With Padding"))
.NameContent()
[
SNew(STextBlock)
.Text(LOCTEXT("With Padding", "With Padding"))
]
.ValueContent()
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot().Padding(10.0f, 0.0f, 35.0f, 0.0f) [ SNew(STextBlock).Text(LOCTEXT("Foo", "Foo")) ]
+SHorizontalBox::Slot().Padding(10.0f, 0.0f, 35.0f, 0.0f) [ prop1->CreatePropertyValueWidget() ]
+SHorizontalBox::Slot().Padding(10.0f, 0.0f, 35.0f, 0.0f) [ SNew(STextBlock).Text(LOCTEXT("Bar", "Bar")) ]
+SHorizontalBox::Slot().Padding(10.0f, 0.0f, 35.0f, 0.0f) [ prop2->CreatePropertyValueWidget() ]
];