From b138388c290f2babe0e386e681d8d73a45b2eb8f Mon Sep 17 00:00:00 2001 From: Thomas Morgner Date: Fri, 16 Nov 2018 12:14:04 +0000 Subject: [PATCH] Allow to trigger renames via F2 key --- Scripts/Editor/NodeEditor.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index fa4e110..3a3c490 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -31,9 +31,20 @@ namespace XNodeEditor { } } else { GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); + if (HasFocus() && IsRenameKeyPressed()) { + InitiateRename(); + } } } + bool HasFocus() { + return Selection.activeObject == this.target; + } + + bool IsRenameKeyPressed() { + return (Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.F2); + } + /// Draws standard field editors for all public fields public virtual void OnBodyGUI() { // Unity specifically requires this to save/update any serial object.