File tree Expand file tree Collapse file tree
Editor/StateGraph/VisualElements Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,11 +29,7 @@ public StateGraphView(string id) : base(id)
2929
3030 MakeToolBar ( ) ;
3131 MakeFooterBar ( ) ;
32- }
33-
34- protected override void MakeStateManager ( string id )
35- {
36- StateManager = new StateNodeGraphStateManager ( id ) ;
32+ RegisterCallback < KeyDownEvent > ( OnKeyDown ) ;
3733 }
3834
3935 public void PopulateGraph ( NodeGraphDataModel model , bool recentre )
@@ -69,7 +65,34 @@ public override void PopulateGraph(NodeGraphDataModel model)
6965 {
7066 PopulateGraph ( model , recentre : true ) ;
7167 }
72-
68+
69+ protected override void MakeStateManager ( string id )
70+ {
71+ StateManager = new StateNodeGraphStateManager ( id ) ;
72+ }
73+
74+ private void OnKeyDown ( KeyDownEvent evt )
75+ {
76+ HandleCopyAndPasteKeys ( evt ) ;
77+ }
78+
79+ private void HandleCopyAndPasteKeys ( KeyDownEvent evt )
80+ {
81+ if ( ! evt . ctrlKey && ! evt . commandKey ) return ;
82+
83+ switch ( evt . keyCode )
84+ {
85+ case KeyCode . C :
86+ HandleCopySelected ( ) ;
87+ evt . StopPropagation ( ) ;
88+ break ;
89+ case KeyCode . V :
90+ HandlePasteSelected ( ) ;
91+ evt . StopPropagation ( ) ;
92+ break ;
93+ }
94+ }
95+
7396 private static void AddEntryNode ( StateMachineModel stateModel )
7497 {
7598 if ( ! stateModel ) return ;
You can’t perform that action at this time.
0 commit comments