Skip to content

Commit

Permalink
Use Double Left Click to trigger NodeAutoComplete (#11710)
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang authored May 25, 2021
1 parent 32c777e commit 24c66bc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 37 deletions.
37 changes: 21 additions & 16 deletions src/DynamoCoreWpf/UI/Themes/Modern/Ports.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Dynamo.Views;assembly=DynamoCore"
xmlns:viewModels="clr-namespace:Dynamo.ViewModels;assembly=DynamoCoreWpf"
xmlns:dynui="clr-namespace:Dynamo.UI.Controls;assembly=DynamoCoreWpf"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:views="clr-namespace:Dynamo.UI.Views;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
xmlns:viewModels="clr-namespace:Dynamo.ViewModels;assembly=DynamoCoreWpf"
xmlns:controls="clr-namespace:Dynamo.Views;assembly=DynamoCore"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf">
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">

<!-- Templates
Expand Down Expand Up @@ -38,17 +38,17 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid
Name="mainGrid"
Grid.Column="0"
Background="Transparent"
IsHitTestVisible="True"
Margin="{Binding Path=MarginThickness}"
Height="{Binding Path=Height}"
ToolTipService.ShowDuration="60000"
IsEnabled="{Binding Path=IsEnabled}">
<Grid Name="mainGrid"
Grid.Column="0"
Background="Transparent"
IsHitTestVisible="True"
Margin="{Binding Path=MarginThickness}"
Height="{Binding Path=Height}"
ToolTipService.ShowDuration="60000"
IsEnabled="{Binding Path=IsEnabled}">

<interactivity:Interaction.Triggers>
<!--Bind Connect command to left click-->
<views:HandlingEventTrigger EventName="MouseLeftButtonDown">
<interactivity:InvokeCommandAction Command="{Binding Path=ConnectCommand}" />
</views:HandlingEventTrigger>
Expand All @@ -72,6 +72,11 @@
</dynui:DynamoToolTip>
</Grid.ToolTip>

<!--Bind NodeAutoComplete to double left click-->
<Grid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding Path=NodeAutoCompleteCommand}"></MouseBinding>
</Grid.InputBindings>

<!--
We could have changed the Grid opacity directly here but didn't
The reason is that if the opacity of the Grid is modified, the
Expand Down Expand Up @@ -228,7 +233,7 @@
Foreground="#555555"/>
</StackPanel>
<dynui:UseLevelPopup
x:Name="MyPopup"
x:Name="UseLevelPopup"
Placement="Right"
AllowsTransparency="True"
IsOpen="{Binding Path=ShowUseLevelMenu}"
Expand Down
17 changes: 6 additions & 11 deletions src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ private bool CanConnect(object parameter)
private void AutoComplete(object parameter)
{
var wsViewModel = _node.WorkspaceViewModel;
var svm = wsViewModel.NodeAutoCompleteSearchViewModel;
svm.PortViewModel = this;

wsViewModel.NodeAutoCompleteSearchViewModel.PortViewModel = this;
// Bail out from connect state
wsViewModel.CancelActiveState();
wsViewModel.OnRequestNodeAutoCompleteSearch(ShowHideFlags.Show);
}

Expand All @@ -427,10 +427,7 @@ private bool CanAutoComplete(object parameter)
/// <param name="parameter">The parameter.</param>
private void OnRectangleMouseEnter(object parameter)
{
if (MouseEnter != null)
{
MouseEnter(parameter, null);
}
MouseEnter?.Invoke(parameter, null);
}

/// <summary>
Expand All @@ -439,8 +436,7 @@ private void OnRectangleMouseEnter(object parameter)
/// <param name="parameter">The parameter.</param>
private void OnRectangleMouseLeave(object parameter)
{
if (MouseLeave != null)
MouseLeave(parameter, null);
MouseLeave?.Invoke(parameter, null);
}

/// <summary>
Expand All @@ -449,8 +445,7 @@ private void OnRectangleMouseLeave(object parameter)
/// <param name="parameter">The parameter.</param>
private void OnRectangleMouseLeftButtonDown(object parameter)
{
if (MouseLeftButtonDown != null)
MouseLeftButtonDown(parameter, null);
MouseLeftButtonDown?.Invoke(parameter, null);
}

/// <summary>
Expand Down
10 changes: 0 additions & 10 deletions src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -802,16 +802,6 @@ internal bool HandlePortClicked(PortViewModel portViewModel)

if (this.currentState != State.Connection) // Not in a connection attempt...
{
if (Keyboard.Modifiers == ModifierKeys.Alt &&
portViewModel.NodeAutoCompleteCommand.CanExecute(portViewModel))
{
portViewModel.NodeAutoCompleteCommand.Execute(portViewModel);
this.currentState = State.Connection;
owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.ArcSelect);
owningWorkspace.IsCursorForced = false;
return true;
}

Guid nodeId = portModel.Owner.GUID;
int portIndex = portModel.Index;

Expand Down

0 comments on commit 24c66bc

Please sign in to comment.