Skip to content

Commit 6de1a82

Browse files
committed
Added support for initiating and completing click-and-drag operations using the keyboard
1 parent 25cb677 commit 6de1a82

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
> - Added Select, BeginSelecting, UpdateSelection, EndSelecting, CancelSelecting and AllowSelectionCancellation to NodifyEditor
2222
> - Added IsDragging, BeginDragging, UpdateDragging, EndDragging and CancelDragging to NodifyEditor
2323
> - Added AlignSelection and AlignContainers methods to NodifyEditor
24-
> - Added HasCustomContextMenu dependency property to NodifyEditor and ItemContainer
24+
> - Added HasCustomContextMenu dependency property to NodifyEditor, ItemContainer and Connector
2525
> - Added Select, BeginDragging, UpdateDragging, EndDragging and CancelDragging to ItemContainer
2626
> - Added PreserveSelectionOnRightClick configuration field to ItemContainer
2727
> - Added BeginConnecting, UpdatePendingConnection, EndConnecting, CancelConnecting and RemoveConnections methods to Connector
2828
> - Added a custom MouseGesture with support for key combinations
2929
> - Added InputProcessor to NodifyEditor, ItemContainer and Connector, enabling the extension of controls with custom states
30-
> - Added ElementOperationState to simplify the creation of complex control states
30+
> - Added DragState to simplify creating click-and-drag operations, with support for initiating and completing them using the keyboard
3131
> - Move the viewport to the mouse position when zooming on the Minimap if ResizeToViewport is false
3232
> - Bugfixes:
3333
> - Fixed an issue where the ItemContainer was selected by releasing the mouse button on it, even when the mouse was not captured
@@ -38,6 +38,7 @@
3838
> - Fixed an issue where controls would capture the mouse unnecessarily; they now capture it only in response to a defined gesture
3939
> - Fixed an issue where the minimap could update the viewport without having the mouse captured
4040
> - Fixed ItemContainer.Select and NodifyEditor.SelectArea to clear the existing selection and select the containers within the same transaction
41+
> - Fixed an issue where editor operations failed to cancel upon losing mouse capture.
4142
4243
#### **Version 6.6.0**
4344

Nodify/Connections/Connector.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,15 @@ protected override void OnKeyUp(KeyEventArgs e)
376376

377377
/// <inheritdoc />
378378
protected override void OnKeyDown(KeyEventArgs e)
379-
=> InputProcessor.Process(e);
379+
{
380+
InputProcessor.Process(e);
381+
382+
// Release the mouse capture if all the mouse buttons are released and there's no sticky connection pending
383+
if (!IsPendingConnection && IsMouseCaptured && Mouse.RightButton == MouseButtonState.Released && Mouse.LeftButton == MouseButtonState.Released && Mouse.MiddleButton == MouseButtonState.Released)
384+
{
385+
ReleaseMouseCapture();
386+
}
387+
}
380388

381389
#endregion
382390

Nodify/ItemContainer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,15 @@ protected override void OnLostMouseCapture(MouseEventArgs e)
396396

397397
/// <inheritdoc />
398398
protected override void OnKeyUp(KeyEventArgs e)
399-
=> InputProcessor.Process(e);
399+
{
400+
InputProcessor.Process(e);
401+
402+
// Release the mouse capture if all the mouse buttons are released
403+
if (IsMouseCaptured && Mouse.RightButton == MouseButtonState.Released && Mouse.LeftButton == MouseButtonState.Released && Mouse.MiddleButton == MouseButtonState.Released)
404+
{
405+
ReleaseMouseCapture();
406+
}
407+
}
400408

401409
/// <inheritdoc />
402410
protected override void OnKeyDown(KeyEventArgs e)

Nodify/NodifyEditor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,15 @@ protected override void OnLostMouseCapture(MouseEventArgs e)
837837

838838
/// <inheritdoc />
839839
protected override void OnKeyUp(KeyEventArgs e)
840-
=> InputProcessor.Process(e);
840+
{
841+
InputProcessor.Process(e);
842+
843+
// Release the mouse capture if all the mouse buttons are released
844+
if (IsMouseCaptured && Mouse.RightButton == MouseButtonState.Released && Mouse.LeftButton == MouseButtonState.Released && Mouse.MiddleButton == MouseButtonState.Released)
845+
{
846+
ReleaseMouseCapture();
847+
}
848+
}
841849

842850
/// <inheritdoc />
843851
protected override void OnKeyDown(KeyEventArgs e)

0 commit comments

Comments
 (0)