x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[HELP] Custom Struct Property Editor Add Setter and Listener

I have been struggling with this for a while and would really appreciate some guidance.

The goal is to create a dropdown list/combo box that contains strings that the user can select in the editor. This is to extend details customization.

I have created a custom structure like so.

 USTRUCT()
 struct FTaskComponentData
 {
     GENERATED_BODY()
 
     UPROPERTY(VisibleAnywhere)
     TArray<FString>                                                Names;
 
 };

Then I have created a class to implement the IPropertyTypeCustomization like so: (Header file):

 class FTaskComponentDataCustomization : public IPropertyTypeCustomization
 {
 public:
     static TSharedRef<IPropertyTypeCustomization> MakeInstance();
  
     /** IPropertyTypeCustomization interface */
     virtual void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
     virtual void CustomizeChildren(TSharedRef<class IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
  
 private:
     TSharedPtr<IPropertyHandle> UPropertyTaskNameHandle;
 
     /** Visibility delegate for the various methods of calculating magnitude */
     EVisibility GetPropertyVisibility(UProperty* InProperty) const;
 };

(Source file):

 TSharedRef<IPropertyTypeCustomization> FTaskComponentDataCustomization::MakeInstance()
 {
     return MakeShareable(new FTaskComponentDataCustomization());
 }
  
 void FTaskComponentDataCustomization::CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
 {
     uint32 NumChildren;
     StructPropertyHandle->GetNumChildren(NumChildren);
  
     for (uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex)
     {
         const TSharedRef< IPropertyHandle > ChildHandle = StructPropertyHandle->GetChildHandle(ChildIndex).ToSharedRef();
  
         if (ChildHandle->GetProperty()->GetName() == TEXT("Names"))
         {
             UPropertyTaskNameHandle = ChildHandle;
         }
     }
  
     check(UPropertyTaskNameHandle.IsValid());
 
 
     static TArray< TSharedPtr<FString>> something;
 
     something.Add(TSharedPtr<FString>(new FString("One")));
     something.Add(TSharedPtr<FString>(new FString("Two")));
     something.Add(TSharedPtr<FString>(new FString("Three")));
 
 
     HeaderRow.NameContent()
         [
             StructPropertyHandle->CreatePropertyNameWidget(LOCTEXT("Task", "Task Names"), LOCTEXT("IDK","IDK"), false, true, false)
         ]
     .ValueContent()
         .MinDesiredWidth(250)
         [
             SNew(STextComboBox)
             .OptionsSource(&something)
         ];
 }
  
 void FTaskComponentDataCustomization::CustomizeChildren(TSharedRef<class IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
 {
 }
  
 
 EVisibility FTaskComponentDataCustomization::GetPropertyVisibility(UProperty* InProperty) const {
     return EVisibility::Visible;
 }


I have then included this custom structure in my component subclass like this:

 UPROPERTY(EditAnywhere, Category = "Planning | Task")
 FTaskComponentData                            TaskData;

I then register with the FPropertyEditorModule like so:

 FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
 
     //Custom properties
     PropertyModule.RegisterCustomPropertyTypeLayout("TaskComponentData", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FTaskComponentDataCustomization::MakeInstance));


At this point, the desired combo box shows up.. I have 2 questions:

1) How can I set TArray so that I can update the data members with different strings?

2) How do I register the property change listener? Right now, none of the property change listeners are fired from my component when I try to select values from my combobox.

Or where do I got to dig up any of this functionality?

Product Version: UE 4.15
Tags:
more ▼

asked Jul 31 '17 at 10:35 PM in C++ Programming

avatar image

jchen114
11 1 6 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question