# \--\> Hide Properties? \<--

**URL:** <https://forums.unrealengine.com/t/hide-properties/779952>\
**Category:** C++\
**Tags:** UProperty, details-panel, unreal-engine, Engine-Source-Code, editor, question, CPP\
**Created:** [February 27, 2023, 8:12pm UTC](https://forums.unrealengine.com/t/hide-properties/779952 "2023-02-27T20:12:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 27, 2023, 8:12pm UTC](https://forums.unrealengine.com/t/hide-properties/779952/1 "2023-02-27T20:12:40Z")

</div>

IDetailLayoutBuilder incorrectly reports properties as visible when they have been hidden and more importantly refuses to hide “inner properties” (meta ShowOnlyInnerProperties). What is wrong with my code??

```auto
	auto HidePropertiesRecursive = [&DetailBuilder](auto&& HidePropertiesRecursive, const FString& InPropertyName, const UClass* InContainerClass) -> bool {
		if (!IsValid(InContainerClass))) {
			// Irrelevant.
			return false;		
		}

		TSharedRef<IPropertyHandle> PropHandleX = DetailBuilder.GetProperty(FName(InPropertyName), InContainerClass);

		CUR_LOG(LogCorePluginEditor, VeryVerbose, "%s: Attempt hide for: %s.", *InContainerClass->GetName(), *InPropertyName);
		if (PropHandleX->HasMetaData(TEXT("ShowOnlyInnerProperties"))) {
			CUR_LOG(LogCorePluginEditor, VeryVerbose, "Recurse into inner property.");

			uint32 OutNum = 0;
			PropHandleX->GetNumChildren(OutNum);
			for (uint32 i = 0; i < OutNum; i++) {
				TSharedPtr<IPropertyHandle> PropY = PropHandleX->GetChildHandle(i);
				if (!PropY->GetProperty()) {
					return false;
				}
				
				if (// Must recurse into the property on the same parent first.
					!HidePropertiesRecursive(HidePropertiesRecursive, PropY->GetProperty()->GetNameCPP(), InContainerClass)
					// Attempt to search inner property on parent class.
					&& !HidePropertiesRecursive(HidePropertiesRecursive, PropY->GetProperty()->GetNameCPP(), InContainerClass->GetSuperClass())
					) {
					return false;
				}
			}

			// Success if we reach this point.
			return true;
		}

		// If we did not have to recurse into an inner property, we can try to hide it.

		DetailBuilder.HideProperty(PropHandleX);

		if (DetailBuilder.IsPropertyVisible(PropHandleX)) {
			// Still visible (failure). Try on the parent class. We must have an exact match where the property was declared.
			return HidePropertiesRecursive(HidePropertiesRecursive, InPropertyName, InContainerClass->GetSuperClass());
		}

		// Success.
		return true;
	};

```

Logs

```auto
Attempt hide for: ThatProperty.
SomeClass: Attempt hide for: ThatProperty.
Recurse into inner property.
SomeClass: Attempt hide for: SomeInnerProperty.
SomeParentClass: Attempt hide for: SomeInnerProperty.
SomeParentClass: Attempt hide for: SomeInnerProperty.

After returning false on the initial call for ThatProperty:
Could not hide the property: ThatProperty.

```

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 27, 2023, 10:36pm UTC](https://forums.unrealengine.com/t/hide-properties/779952/2 "2023-02-27T22:36:25Z")

</div>

Turns out this is not enough

```auto
DetailBuilder.HideProperty(MyPropHandle);

```

if

```auto
MyPropHandle->HasMetaData(TEXT("ShowOnlyInnerProperties"))

```

You have to browse through it recursively and hide the inner properties too.

Additionally it seems you can only find the property handle on the exact UClass it was declared on.
