diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 651824a..1258983 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -255,6 +255,11 @@ namespace XNodeEditor { case EventType.KeyDown: if (EditorGUIUtility.editingTextField) break; else if (e.keyCode == KeyCode.F) Home(); + if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX) { + if (e.keyCode == KeyCode.Return) RenameSelectedNode(); + } else { + if (e.keyCode == KeyCode.F2) RenameSelectedNode(); + } break; case EventType.ValidateCommand: if (e.commandName == "SoftDelete") RemoveSelectedNodes(); @@ -318,6 +323,14 @@ namespace XNodeEditor { } } + /// Initiate a rename on the currently selected node + public void RenameSelectedNode() { + if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { + XNode.Node node = Selection.activeObject as XNode.Node; + NodeEditor.GetEditor(node).InitiateRename(); + } + } + /// Draw this node on top of other nodes by placing it last in the graph.nodes list public void MoveNodeToTop(XNode.Node node) { int index; diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 34cd210..51baf55 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -112,7 +112,7 @@ namespace XNodeEditor { if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { XNode.Node node = Selection.activeObject as XNode.Node; contextMenu.AddItem(new GUIContent("Move To Top"), false, () => MoveNodeToTop(node)); - contextMenu.AddItem(new GUIContent("Rename"), false, NodeEditor.GetEditor(node).InitiateRename); + contextMenu.AddItem(new GUIContent("Rename"), false, RenameSelectedNode); } contextMenu.AddItem(new GUIContent("Duplicate"), false, DublicateSelectedNodes);