Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public abstract class Tree
[SerializeField] private TreeNodeDictionary folders = new TreeNodeDictionary();

[NonSerialized] private Stack<bool> indents = new Stack<bool>();
[NonSerialized] private Action<TreeNode> rightClickNextRender;
[NonSerialized] private TreeNode rightClickNextRenderNode;

public bool IsInitialized { get { return nodes != null && nodes.Count > 0 && !String.IsNullOrEmpty(nodes[0].Name); } }
public bool RequiresRepaint { get; private set; }
Expand Down Expand Up @@ -134,6 +136,16 @@ public void Load(IEnumerable<ITreeData> data, string title)

public Rect Render(Rect rect, Vector2 scroll, Action<TreeNode> singleClick = null, Action<TreeNode> doubleClick = null, Action<TreeNode> rightClick = null)
{
if (Event.current.type != EventType.Repaint)
{
if (rightClickNextRender != null)
{
rightClickNextRender.Invoke(rightClickNextRenderNode);
rightClickNextRender = null;
rightClickNextRenderNode = null;
}
}

Profiler.BeginSample("TreeControl");
bool visible = true;
var availableHeight = rect.y + rect.height;
Expand Down Expand Up @@ -274,7 +286,8 @@ private bool HandleInput(Rect rect, TreeNode currentNode, int index, Action<Tree
}
if (mouseButton == 1 && clickCount == 1 && rightClick != null)
{
rightClick(currentNode);
rightClickNextRender = rightClick;
rightClickNextRenderNode = currentNode;
}
}

Expand Down