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

Use Double Left Click to trigger NodeAutoComplete #11710

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bind NodeAutoComplete to double left click here using Grid.InputBindings since Grid does not expose double left click event directly


<!--
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;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting the old code handling Alt+ mouse left click to trigger node Autocomplete


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

Expand Down