# IDetailCustomization - any tips for using it?

**URL:** <https://forums.unrealengine.com/t/idetailcustomization-any-tips-for-using-it/100049>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [September 18, 2017, 9:31am UTC](https://forums.unrealengine.com/t/idetailcustomization-any-tips-for-using-it/100049 "2017-09-18T09:31:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Semitable](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Semitable](https://forums.unrealengine.com/u/Semitable)\
**Post date:** [September 18, 2017, 10:43am UTC](https://forums.unrealengine.com/t/idetailcustomization-any-tips-for-using-it/100049/2 "2017-09-18T10:43:18Z")

</div>

Hey! Actually, I was able to get things going using the wiki: [A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums](https://wiki.unrealengine.com/Customizing_detail_panels)  
Also, the docs ([https://docs.unrealengine.com/latest…Customization/](https://docs.unrealengine.com/latest/INT/Programming/Slate/DetailsCustomization/)) while outdated (the code won’t work I think), it requires minor modifications to work.

Here is some of my code which will help you find what exactly is outdated in the docs (and with what you should replace it!)

```auto

/* .h */

#include "CoreMinimal.h"
#include "IDetailCustomization.h"
class IPropertyHandle;
class IDetailChildrenBuilder;

class FResourceGeneratorDetails : public IDetailCustomization
{
public:

    static TSharedRef<IDetailCustomization> MakeInstance();

    virtual void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override;
protected:

    void GenerateRecipeArrayElementWidget(TSharedRef<IPropertyHandle> ChildHandle, int32 ArrayIndex, IDetailChildrenBuilder& ChildrenBuilder, IDetailLayoutBuilder* DetailLayout);

private:

    void ShareRecipeKeys();

    TArray<TSharedPtr<FName>> RecipeKeys;

    //TSharedPtr<IPropertyHandle> CurrentHandle;
};

```

and the cpp:

```auto

...
#include "DetailCategoryBuilder.h"
#include "DetailLayoutBuilder.h"
#include "IDetailChildrenBuilder.h"
#include "IDetailPropertyRow.h"

#include "PropertyHandle.h"

#include "DetailWidgetRow.h"
#include "STextBlock.h"
#include "SComboBox.h"
#include "SWidget.h"
#include "PropertyCustomizationHelpers.h"

#define LOCTEXT_NAMESPACE "ResourceGeneratorDetails"

TSharedRef<IDetailCustomization> FResourceGeneratorDetails::MakeInstance()
{
    return MakeShareable(new FResourceGeneratorDetails);
}

void FResourceGeneratorDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
{
    ShareRecipeKeys();
    // Create a category so this is displayed early in the properties
    IDetailCategoryBuilder& CraftingCategory = DetailBuilder.EditCategory("Crafting", FText::FromString(TEXT("Crafting")), ECategoryPriority::Important);

    //You can get properties using the detailbuilder
    //MyProperty= DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(MyClass, MyClassPropertyName));
    TSharedPtr<IPropertyHandle> RecipesProperty = DetailBuilder.GetProperty("Recipes");
    TSharedRef<FDetailArrayBuilder> RecipesArrayPropertyBuilder = MakeShareable(new FDetailArrayBuilder(RecipesProperty.ToSharedRef()));

    RecipesArrayPropertyBuilder->OnGenerateArrayElementWidget(FOnGenerateArrayElementWidget::CreateSP(this, &FResourceGeneratorDetails::GenerateRecipeArrayElementWidget, &DetailBuilder));
    CraftingCategory.AddCustomBuilder(RecipesArrayPropertyBuilder, false);
}

void FResourceGeneratorDetails::GenerateRecipeArrayElementWidget(TSharedRef<IPropertyHandle> ChildHandle, int32 ArrayIndex, IDetailChildrenBuilder& ChildrenBuilder, IDetailLayoutBuilder* DetailLayout)
{

    IDetailPropertyRow& PropertyArrayRow = ChildrenBuilder.AddProperty(ChildHandle);

    PropertyArrayRow.CustomWidget()
    .NameContent()
    
        ChildHandle->CreatePropertyNameWidget()
    ]
    .ValueContent()
    
        SNew(SHorizontalBox)
        + SHorizontalBox::Slot()
        
            SNew(SComboBox<TSharedPtr<FName>>)
            .OptionsSource(&RecipeKeys)
            .OnGenerateWidget_Lambda ( ](TSharedPtr<FName> InItem) {
                return SNew(STextBlock)
                .Text(FText::FromName(*InItem));
            })
            .OnSelectionChanged_Lambda(=](TSharedPtr<FName> Selection, ESelectInfo::Type){
                if (ChildHandle->IsValidHandle()) {
                    ChildHandle->SetValue(*Selection);
                }
            })
            .ContentPadding(FMargin(2, 0))
            
                SNew(STextBlock)
                .Font(IDetailLayoutBuilder::GetDetailFont())
                .Text_Lambda( =]() -> FText
                {
                    if (ChildHandle->IsValidHandle())
                    {
                        FName val;
                        ChildHandle->GetValue(val);
                        return FText::FromName(val);
                    }

                    return FText::GetEmpty();
                } )
            ]
        ]
    ];

}

void FResourceGeneratorDetails::ShareRecipeKeys()
{
    TArray<FName> AllKeys = UETPStatics::GetCraftingRecipeKeys();
    RecipeKeys.Empty(AllKeys.Num());

    for (FName key : AllKeys) {
        RecipeKeys.Add(MakeShareable(new FName(key)));
    }
}

#undef LOCTEXT_NAMESPACE

```

Excuse me for not cleaning up the code; nevertheless, I think you will find this (more complicated) example more useful since it is a collection of various tutorials/digging through engine code.  
What it actually does is create a drop-down menu for values in an ARRAY. The values that are shown are found in GetCraftingRecipeKeys() so ignore (or replace) it.

For something simple you should just keep the CustomizeDetails()

Don’t forget to register your customization through StartupModule() using:

```auto

    PropertyModule.RegisterCustomClassLayout("ResourceGenerator", FOnGetDetailCustomizationInstance::CreateStatic(&FResourceGeneratorDetails::MakeInstance));

```

If you don’t have a module yet you should follow this:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Hope I helped a bit, good luck 🙂

---

_[View the full topic](https://forums.unrealengine.com/t/idetailcustomization-any-tips-for-using-it/100049)._
