1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-22 02:06:05 +08:00

Added F2 to rename hotkey (return on mac)

This commit is contained in:
Thor Brigsted 2018-04-18 12:57:12 +02:00
parent 69ee12169d
commit 75795c59b0
2 changed files with 14 additions and 1 deletions

View File

@ -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 {
}
}
/// <summary> Initiate a rename on the currently selected node </summary>
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();
}
}
/// <summary> Draw this node on top of other nodes by placing it last in the graph.nodes list </summary>
public void MoveNodeToTop(XNode.Node node) {
int index;

View File

@ -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);