How to use IPropertyTypeCustomization to display TArray

Hi, I have a struct and I’m trying to create a custom inspector. I know how to create widgets for all the simple types of data (bool, int, string, enum, vector, color, actor, ect). I found examples of that in the engine source, but I cant find how to display an array.

So far i have this:

void UnrealEventCustomization::CustomizeChildren(TSharedRef<class IPropertyHandle> StructPropertyHandle, IDetailChildrenBuilder & StructBuilder, IPropertyTypeCustomizationUtils & StructCustomizationUtils)
{
	if (StructPropertyHandle->IsValidHandle() == false)
		return;

	TSharedPtr < IPropertyHandle > StringsHandle = StructPropertyHandle->GetChildHandle(TEXT("Strings"), false);
	TSharedPtr <IPropertyHandleArray> StringsArrayHandle = StringsHandle->AsArray();

	FDetailWidgetRow& fullStringsRow = StructBuilder.AddCustomRow(FText::FromString("Some Strings"));
	fullStringsRow.NameContent()
		[

			StringsHandle->CreatePropertyNameWidget()
		]
	.ValueContent().MinDesiredWidth(500)
		[


			StringsHandle->CreatePropertyValueWidget(true)
		];
}

and the result is this:

227130-capture.png

It displays my array property (named Strings) but it has no dropdown button.
Under it there’s the default slate ui for an array and as you can see, it has the small dropdown button on the left side and when you press that, it expands and displays all the elements of the array.

How do i do that in my custom inspector ?

Are you defining header function as well?

void UnrealEventCustomization::CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
    	// ....
}

Yes, I am.

The reason I posted this question is because I thought there would be some easy way of doing it.
Just like there is with the actor picker dropdown. The PropertyCustomizationHelpers has a function called MakeActorPickerWithMenu and that function creates this widget:

227211-capture3.png

I thought there would be something similar for the array dropdown since a lot of the editor ui parts makes use of it. You know, automate every repetetive task…

Another thing that made me believe there must be an easy/short way of doing it is the Widget Reflector (Window → Developer Tools → Widget Reflector)

The Widget Reflector says that the arrow dropdown button that i’m trying to create is actually already created with the code above, it’s just hidden. So I thought all i need to do is just maybe enable something somewhere and that’s it.

Now i’m starting to believe I need to iterate through all the array elements and create the dropdown myself, because i just cant find anything like what i described.

Still, you can find arrays in many Editor UI parts, there must be an easy way of creating the widgets, right…?

Basically, what I’m looking for is the UE4 equivalent of Unity’s DrawDefaultInspector (). And if there is something like that for a single property, that would be great. Draw one the default way, customize another… that’s what I’m looking for :smiley:

I am working on a custom property panel for a custom UObject where I change the way a TArray is drawn:

But I’m not sure what exactly you’re trying to do. If you want to draw an array the same way the UEditor does then you don’t need customizations.
If you want to change the way just one property is drawn then it won’t affect any other properties, just the one you’re customizing.

How do you customize the way that only one property from a struct is drawn ? I have a custom struct. Let’s say it has an bool, an int and an array of strings and I just want to customize the bool and int and for the array, i just want what the editor ui is already doing when you don’t use IPropertyTypeCustomization. How do i do that ?

The moment you inject custom drawing to the Struct the whole struct drawing is now your responsibility ^^
If there’s a way to draw some members of the struct and leave the others using default widgets I don’t know.

Btw, if you call MyArrayHandle->CreatePropertyNameWidget() in the struct’s customizer then you’ll draw the name of the array with that little dropdown arrow attached. (oh but you already do that, sry)

I particularly call HeaderRow.WholeRowContent() on the structs and draw everything manually with custom widgets inherited from SCompoundWidget class.

I appreciate you taking the time to help me.
I tried “CreatePropertyNameWidget()” and it does not add the little arrow, you can see in my top post, I also added a screenshot there, the first screenshot. No little arrow :frowning:

It’s not really clear exactly what you’re trying to do, but you might want to check out FDetailArrayBuilder, which makes working with customizations for arrays much easier (e.g., if you want to customize the name of an array entry row to be something more useful than the index of the array entry). There’s an example in FSpriteDetailsCustomization, in order to label the AdditionalTextures array nicely.

RE: The drop-down for add/delete/reset to defaults, that is probably controlled by the ‘bDisplayDefaultPropertyButtons’ parameter of CreatePropertyValueWidget.

Cheers,
Michael Noland

1 Like

Yes, thank you.
To be more clear, I wanted to recreate the default layout for a TArray property in my custom interface (the expand, the reorder handles, the add/delete/reset, everything). And yes, the example from FSpriteDetailsCustomization::BuildTextureSection gave me everything I needed.

1 Like