//Handles events, Mouse downs, ups etc.
        static void HandleEvents(Node node, Event e) {

            //Node click
            if ( e.type == EventType.MouseDown && GraphEditorUtility.allowClick && e.button != 2 ) {

                Undo.RegisterCompleteObjectUndo(node.graph, "Move Node");

                if ( !e.control ) {
                    GraphEditorUtility.activeElement = node;
                }

                if ( e.control ) {
                    if ( node.isSelected ) { GraphEditorUtility.activeElements.Remove(node); } else { GraphEditorUtility.activeElements.Add(node); }
                }

                if ( e.button == 0 ) {
                    node.nodeIsPressed = true;
                }

                //Double click
                if ( e.button == 0 && e.clickCount == 2 ) {
                    if ( node is IGraphAssignable && ( node as IGraphAssignable ).nestedGraph != null ) {
                        node.graph.currentChildGraph = ( node as IGraphAssignable ).nestedGraph;
                        node.nodeIsPressed = false;
                    } else if ( node is ITaskAssignable && ( node as ITaskAssignable ).task != null ) {
                        EditorUtils.OpenScriptOfType(( node as ITaskAssignable ).task.GetType());
                    } else {
                        EditorUtils.OpenScriptOfType(node.GetType());
                    }
                    e.Use();
                }

                node.OnNodePicked();
            }

            //Mouse up
            if ( e.type == EventType.MouseUp ) {
                if ( node.nodeIsPressed ) {
                    node.TrySortConnectionsByPositionX();
                }
                node.nodeIsPressed = false;
                node.OnNodeReleased();
            }
        }