Skip to content

Commit 44c3164

Browse files
authored
Merge pull request #213 from miroiu/fix/212-select-all-gesture
Fixe the assumption that the ApplicationCommands.SelectAll is a KeyGesture
2 parents e4ae826 + 23cde0d commit 44c3164

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
> - Breaking Changes:
66
> - Features:
7+
> - Added AsRef extension method to InputGesture to convert it to an InputGestureRef
78
> - Bugfixes:
9+
> - Fixed an issue where the gesture used for EditorGestures.Editor.SelectAll extracted from the ApplicationCommands was assumed to be a KeyGesture
810
911
#### **Version 7.0.3**
1012

Nodify/Interactivity/Gestures/EditorGestures.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public class NodifyEditorGestures
150150
public NodifyEditorGestures()
151151
{
152152
Selection = new SelectionGestures();
153-
SelectAll = (KeyGesture)ApplicationCommands.SelectAll.InputGestures[0];
153+
SelectAll = ApplicationCommands.SelectAll.InputGestures[0].AsRef();
154154
Cutting = new MouseGesture(MouseAction.LeftClick, ModifierKeys.Alt | ModifierKeys.Shift, true);
155155
PushItems = new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control | ModifierKeys.Shift, true);
156156
Pan = new AnyGesture(new MouseGesture(MouseAction.RightClick), new MouseGesture(MouseAction.MiddleClick));

Nodify/Interactivity/Gestures/InputGestureRef.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public sealed class InputGestureRef : InputGesture
1313

1414
private InputGestureRef() { }
1515

16+
internal InputGestureRef(InputGesture gesture)
17+
{
18+
Value = gesture;
19+
}
20+
1621
public override bool Matches(object targetElement, InputEventArgs inputEventArgs)
1722
{
1823
return Value.Matches(targetElement, inputEventArgs);
@@ -36,4 +41,18 @@ public static implicit operator InputGestureRef(MultiGesture gesture)
3641
public void Unbind()
3742
=> Value = MultiGesture.None;
3843
}
44+
45+
/// <summary>
46+
/// Extension methods for the <see cref="InputGestureRef"/> class.
47+
/// </summary>
48+
public static class InputGestureRefExtensions
49+
{
50+
/// <summary>
51+
/// Creates a new <see cref="InputGestureRef"/> from the specified gesture.
52+
/// </summary>
53+
public static InputGestureRef AsRef(this InputGesture gesture)
54+
{
55+
return new InputGestureRef(gesture);
56+
}
57+
}
3958
}

0 commit comments

Comments
 (0)