Fix panning Visject Surface with middle mouse button (right button does it) to prevent missed connections removals
#2420
This commit is contained in:
@@ -17,6 +17,11 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly InputActionsContainer InputActions;
|
public readonly InputActionsContainer InputActions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional feature.
|
||||||
|
/// </summary>
|
||||||
|
public bool PanWithMiddleMouse = false;
|
||||||
|
|
||||||
private string _currentInputText = string.Empty;
|
private string _currentInputText = string.Empty;
|
||||||
private Float2 _movingNodesDelta;
|
private Float2 _movingNodesDelta;
|
||||||
private HashSet<SurfaceNode> _movingNodes;
|
private HashSet<SurfaceNode> _movingNodes;
|
||||||
@@ -223,15 +228,18 @@ namespace FlaxEditor.Surface
|
|||||||
|
|
||||||
if (_middleMouseDown)
|
if (_middleMouseDown)
|
||||||
{
|
{
|
||||||
// Calculate delta
|
if (PanWithMiddleMouse)
|
||||||
var delta = location - _middleMouseDownPos;
|
|
||||||
if (delta.LengthSquared > 0.01f)
|
|
||||||
{
|
{
|
||||||
// Move view
|
// Calculate delta
|
||||||
_mouseMoveAmount += delta.Length;
|
var delta = location - _middleMouseDownPos;
|
||||||
_rootControl.Location += delta;
|
if (delta.LengthSquared > 0.01f)
|
||||||
_middleMouseDownPos = location;
|
{
|
||||||
Cursor = CursorType.SizeAll;
|
// Move view
|
||||||
|
_mouseMoveAmount += delta.Length;
|
||||||
|
_rootControl.Location += delta;
|
||||||
|
_middleMouseDownPos = location;
|
||||||
|
Cursor = CursorType.SizeAll;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled
|
// Handled
|
||||||
@@ -300,7 +308,8 @@ namespace FlaxEditor.Surface
|
|||||||
if (_middleMouseDown)
|
if (_middleMouseDown)
|
||||||
{
|
{
|
||||||
_middleMouseDown = false;
|
_middleMouseDown = false;
|
||||||
Cursor = CursorType.Default;
|
if (PanWithMiddleMouse)
|
||||||
|
Cursor = CursorType.Default;
|
||||||
}
|
}
|
||||||
_isMovingSelection = false;
|
_isMovingSelection = false;
|
||||||
ConnectingEnd(null);
|
ConnectingEnd(null);
|
||||||
@@ -483,7 +492,7 @@ namespace FlaxEditor.Surface
|
|||||||
Focus();
|
Focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_rightMouseDown || _middleMouseDown)
|
if (_rightMouseDown || (_middleMouseDown && _middleMouseDown))
|
||||||
{
|
{
|
||||||
// Start navigating
|
// Start navigating
|
||||||
StartMouseCapture();
|
StartMouseCapture();
|
||||||
@@ -555,9 +564,12 @@ namespace FlaxEditor.Surface
|
|||||||
if (_middleMouseDown && button == MouseButton.Middle)
|
if (_middleMouseDown && button == MouseButton.Middle)
|
||||||
{
|
{
|
||||||
_middleMouseDown = false;
|
_middleMouseDown = false;
|
||||||
EndMouseCapture();
|
if (_middleMouseDown)
|
||||||
Cursor = CursorType.Default;
|
{
|
||||||
if (_mouseMoveAmount > 0)
|
EndMouseCapture();
|
||||||
|
Cursor = CursorType.Default;
|
||||||
|
}
|
||||||
|
if (_mouseMoveAmount > 0 && _middleMouseDown)
|
||||||
_mouseMoveAmount = 0;
|
_mouseMoveAmount = 0;
|
||||||
else if (CanEdit)
|
else if (CanEdit)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user