public TreeNodeCanvas() { OnMouseClick.Add(MouseClick); OnMouseDown.Add((k, e) => { if (e.Event.button == 2 || e.Event.button == 1) { _down = true; } }); OnMouseUp.Add((k, e) => { if (e.Event.button == 2 || e.Event.button == 1) { _down = false; } }); OnKeyDown.Add((k, e) => { switch (e.Event.keyCode) { case KeyCode.Delete: BeTreeNode node = _curSelected; if (_curSelected == null) { return; } DeleteItem(node); break; case KeyCode.Escape: if (_curSelected != null) { SelectedNode(null); break; } if (EditorUtility.DisplayDialog("Close window", "You will lose all the unsafed data.", "Confirm", "Cancel")) { (Root as EditorWindow).Close(); } break; case KeyCode.S: if (e.Event.control) { if (e.Event.alt) { OnSaveToJson?.Invoke(); } else { OnSave?.Invoke(); } } break; case KeyCode.O: if (e.Event.control && e.Event.alt) { OpenPanel(); } break; case KeyCode.N: if (e.Event.control && e.Event.alt) { if (!e.Event.shift) { CreatePanel("prefab"); } else { CreatePanel("txt"); } } break; } }); }