internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e) { if (false != ignoreMouseClick) { ignoreMouseClick = false; return(false); } MouseClickHistory curClick = new MouseClickHistory(sender, e); bool eventHandled = false; bool returnFocusToSearch = true; if (this.currentState == State.Connection) { // Clicking on the canvas while connecting simply cancels // the operation and drop the temporary connector. SetCurrentState(State.None); eventHandled = true; // Mouse event handled. } else if (this.currentState == State.None) { // Record the mouse down position. IInputElement element = sender as IInputElement; mouseDownPos = e.GetPosition(element); // We'll see if there is any node being clicked on. If so, // then the state machine should initiate a drag operation. if (null != GetSelectableFromPoint(mouseDownPos)) { InitiateDragSequence(); } else if (e.Source is Dynamo.Controls.EndlessGrid && MouseClickHistory.CheckIsDoubleClick(prevClick, curClick)) { CreateCodeBlockNode(mouseDownPos); // Double clicking on background (EndlessGrid) returnFocusToSearch = false; // Keep the focus on newly created code block node. prevClick = null; } else { InitiateWindowSelectionSequence(); } prevClick = curClick; eventHandled = true; // Mouse event handled. } else if (this.currentState == State.PanMode) { owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.HandPanActive); } if (returnFocusToSearch != false) { dynSettings.ReturnFocusToSearch(); } return(eventHandled); }
internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e) { if (false != ignoreMouseClick) { ignoreMouseClick = false; return(false); } MouseClickHistory curClick = new MouseClickHistory(sender, e); bool eventHandled = false; bool returnFocusToSearch = true; if (this.currentState == State.Connection) { // Clicking on the canvas while connecting simply cancels // the operation and drop the temporary connector. SetCurrentState(State.None); eventHandled = true; // Mouse event handled. } else if (this.currentState == State.None) { // Record the mouse down position. IInputElement element = sender as IInputElement; mouseDownPos = e.GetPosition(element); // We'll see if there is any node being clicked on. If so, // then the state machine should initiate a drag operation. if (null != GetSelectableFromPoint(mouseDownPos)) { InitiateDragSequence(); returnFocusToSearch = ShouldDraggingReturnFocusToSearch(); } else { if ((e.Source is Dynamo.Controls.EndlessGrid) == false) { InitiateWindowSelectionSequence(); } else if (!MouseClickHistory.CheckIsDoubleClick(prevClick, curClick)) { InitiateWindowSelectionSequence(); } else { // Double-clicking on the background grid results in // a code block node being created, in which case we // should keep the input focus on the code block to // avoid it being dismissed (with empty content). // CreateCodeBlockNode(mouseDownPos); returnFocusToSearch = false; curClick = null; } } prevClick = curClick; eventHandled = true; // Mouse event handled. } else if (this.currentState == State.PanMode) { var c = CursorLibrary.GetCursor(CursorSet.HandPanActive); owningWorkspace.CurrentCursor = c; } else if (this.currentState == State.OrbitMode) { var c = CursorLibrary.GetCursor(CursorSet.HandPanActive); owningWorkspace.CurrentCursor = c; } if (returnFocusToSearch != false) { owningWorkspace.DynamoViewModel.ReturnFocusToSearch(); } return(eventHandled); }