Extending an Editor with Slate. How to show a struct property?


I’m in the process of editor extending. I need to show something similar to DetailsView, but with every property as separate entry in the ListView columns. I’t easy to do for a non struct fields - I’m using FPropertyEditorModule::CreateSingleProperty(). But if a property is a struct, marked as USTRUCT() I need something different. It seems that FPropertyEditorModule::CreateStructureDetailView() shoould fit but I can’t understand how to use it. How can I convert my struct to TSharedPtr StructData?


Apologies for the delay in getting back to you; this was assigned to me while I was on vacation.

You can find an example of using FPropertyEditorModule::CreateStructureDetailView in the Data Table editor (see SRowEditor::Construct).

You would need to call IStructureDetailsView::SetStructureData to let it know what struct data it should be viewing. This takes an FStructOnScope instance, which should be constructed with the correct UStruct for your property (see UStructProperty::Struct), and also the raw data for your struct property (as this is what the property editor will edit).



We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.


Thank you for the answer.

This takes an FStructOnScope instance,
which should be constructed with the
correct UStruct for your property, and
also the raw data for your struct

How can I construct this FStructOnScope with the raw data for my struct? It have only one constructor which takes UStruct* only. And can you please bring some light what is the purpose of this structure at all?

Ah, my apologies. I was looking at the latest code, where FStructOnScope has an extra constructor that will take a non-owning reference to some struct data, however this won’t go out in a build until 4.11.

Okay, what you’ll want to do instead is create your own custom FStructOnScope type. We have an example of this for the data table row editor, see FStructFromDataTable, and yours would likely want to take an UStructProperty* and then override the functions to return the UStructProperty::Struct from GetStruct, and the property data from GetStructMemory.

FStructOnScope itself is used to abstract away the struct data from the property editor, and make sure it can be safely destroyed without crashing the editor. The interface itself is a little weird, and I suspect it was extended from its earlier role in the Blueprint VM.

Thank you very much. I extended FStructOnScope and now it seems it works. Thanks!

I’m okay with this.