handle generic treeitem metadata better

This commit is contained in:
Matt Parker
2025-10-10 18:34:31 +10:00
parent 5f2680f33e
commit f2fa4076e2
2 changed files with 21 additions and 3 deletions

View File

@@ -34,6 +34,19 @@ public static class ControlExtensions
public static class NodeExtensions
{
extension(TreeItem treeItem)
{
public T? GetTypedMetadata<T>(int column) where T : RefCounted?
{
var metadata = treeItem.GetMetadata(column);
var refCountedMetadata = metadata.As<RefCounted?>();
if (refCountedMetadata is T correctTypeContainer)
{
return correctTypeContainer;
}
return null;
}
}
extension(Node node)
{
public void QueueFreeChildren()