Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent node autocomplete from autohiding #11487

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ internal void CancelActiveState()
stateMachine.CancelActiveState();
}

internal DateTime GetLastStateTimestamp()
{
return stateMachine.Timestamp;
}

internal void BeginDragSelection(Point2D mouseCursor)
{
// This represents the first mouse-move event after the mouse-down
Expand Down Expand Up @@ -444,11 +439,6 @@ private enum State
#endregion

#region Public Class Properties
/// <summary>
/// Optionally record the last time a particular state is updated.
/// Currently only used for Node AutoComplete feature.
/// </summary>
internal DateTime Timestamp { get; set; }

internal bool IsInIdleState
{
Expand Down Expand Up @@ -819,7 +809,6 @@ internal bool HandlePortClicked(PortViewModel portViewModel)
this.currentState = State.Connection;
owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.ArcSelect);
owningWorkspace.IsCursorForced = false;
Timestamp = DateTime.Now;
return true;
}

Expand Down
19 changes: 11 additions & 8 deletions src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public enum CursorState
private double currentNodeCascadeOffset;
private Point inCanvasSearchPosition;
private List<DependencyObject> hitResultsList = new List<DependencyObject>();
private bool isAutoCompleteLoading;

public WorkspaceViewModel ViewModel
{
Expand Down Expand Up @@ -164,6 +165,14 @@ void OnWorkspaceViewUnloaded(object sender, RoutedEventArgs e)

private void ShowHideNodeAutoCompleteControl(ShowHideFlags flag)
{
// Prevents hiding the dialog from releasing the left mouse button
if (flag == ShowHideFlags.Hide && isAutoCompleteLoading)
{
isAutoCompleteLoading = false;
return;
}

isAutoCompleteLoading = flag == ShowHideFlags.Show && !NodeAutoCompleteSearchBar.IsOpen;
ShowHidePopup(flag, NodeAutoCompleteSearchBar);
}

Expand Down Expand Up @@ -214,13 +223,8 @@ public void HidePopUp()
}
if (NodeAutoCompleteSearchBar.IsOpen)
{
// Suppress the mouse action from last 0.2 second otherwise mouse button release
// in Dynamo window will forcefully shutdown all the open SearchBars
if ((new TimeSpan(DateTime.Now.Ticks - ViewModel.GetLastStateTimestamp().Ticks)).TotalSeconds > 0.2)
{
ShowHideNodeAutoCompleteControl(ShowHideFlags.Hide);
ViewModel.CancelActiveState();
}
ShowHideNodeAutoCompleteControl(ShowHideFlags.Hide);
ViewModel.CancelActiveState();
}
}

Expand Down Expand Up @@ -390,7 +394,6 @@ void OnWorkspaceViewDataContextChanged(object sender, DependencyPropertyChangedE
ViewModel.RequestAddViewToOuterCanvas += vm_RequestAddViewToOuterCanvas;
ViewModel.WorkspacePropertyEditRequested += VmOnWorkspacePropertyEditRequested;
ViewModel.RequestSelectionBoxUpdate += VmOnRequestSelectionBoxUpdate;
ViewModel.RequestNodeAutoCompleteSearch += ShowHideNodeAutoCompleteControl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember this was added so that Node AutoComplete works for custom node workspace. Any reason of removing this? If intended, would you test using node autocomplete in a new custom node?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. This was causing the Show function to be called two times in a row. I can add it back to avoid affecting custom nodes, but it does seem suspicious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this handler assignment I removed the other one. Tested in both standard and custom node workspace and it's working. This also prevents the existing behaviour of the handler being called twice on standard workspaces.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mmisol . Looks reasonable,


ViewModel.Loaded();
}
Expand Down