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

[Bug] Nodes cannot be moved with the mouse in version 7.0.0 #199

Open
shiguHa opened this issue Jan 10, 2025 · 9 comments · May be fixed by #201
Open

[Bug] Nodes cannot be moved with the mouse in version 7.0.0 #199

shiguHa opened this issue Jan 10, 2025 · 9 comments · May be fixed by #201
Assignees
Labels
bug Something isn't working

Comments

@shiguHa
Copy link

shiguHa commented Jan 10, 2025

Describe the bug
When using version 7.0.0 nodes cannot be moved with the mouse. This issue does not occur in version 6.6.0, where nodes can be moved as expected.

To Reproduce

  1. Add version 7.0.0 of the Nodeify library to your WPF .Net8 project. (not installed other libraries)
  2. Use the following XAML code to place a NodifyEditor and so.

https://github.com/miroiu/nodify/wiki/Nodes-Overview

<Window x:Class="LeanNodify.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:LeanNodify"
        xmlns:nodify="clr-namespace:Nodify;assembly=Nodify"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <nodify:NodifyEditor>
            <nodify:NodifyEditor.ItemsSource>
                <CompositeCollection>
                    <nodify:StateNode Content="My node" />
                </CompositeCollection>
            </nodify:NodifyEditor.ItemsSource>
        </nodify:NodifyEditor>
    </Grid>
</Window>
  1. Run the application and try to drag the node with the mouse.

Expected behavior
The node should be draggable and movable with the mouse.

Additional context

This issue does not occur in version 6.6.0, where nodes can be moved as expected.

Environment

  • Nodify Version: 7.0.0
  • Windows11 Home
  • VisualStudio2022
  • .NET Version: 8
@shiguHa shiguHa added the bug Something isn't working label Jan 10, 2025
@jpk6789
Copy link
Contributor

jpk6789 commented Jan 10, 2025

Hi,

I tested this what you said and I can not reproduce your problems. I created a new .Net8.0 project, added Nodify 7.0.0, copied your code and let it run on the same type of system you mentioned (Win 11, Visual Studio 2022) and it worked as expected. See the attached video:

2025-01-10.17-28-07.mp4

Are there maybe other circumstances, which lead to this behavior?

@miroiu
Copy link
Owner

miroiu commented Jan 10, 2025

I tested the same thing and could not reproduce it. Did you customize any gesture or did you change the NodifyEditor.MouseActionSuppressionThreshold?

@shiguHa
Copy link
Author

shiguHa commented Jan 11, 2025

Thank you for your swift response and tested!!

See the attached video.
I created a new .Net8.0 project, added Nodify 7.0.0.
I change it to version 6.6.0 it works as expected.

IssueNodifyMove2025-01-11.mp4

I tested the same thing and could not reproduce it. Did you customize any gesture or did you change the NodifyEditor.MouseActionSuppressionThreshold?

Not custmize any gesture and not change the NodifyEditor.MouseActionSuppressionThreshold

Has the operation method changed in ver7.0.0 from ver6.6.0?
Just left-click and drag the mouse on the node, right?

If there is anything I can do please say so!

@miroiu
Copy link
Owner

miroiu commented Jan 13, 2025

Can you try the following code and let me know what's written in the output window? And is it only the StateNode that doesn't work? Did you also try dragging a Node?

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    static MainWindow()
    {
        InputProcessor.Shared<ItemContainer>.RegisterHandlerFactory(editor => new CustomInputHandler());
    }

    private class CustomInputHandler : IInputHandler
    {
        public bool RequiresInputCapture => false;

        public void HandleEvent(InputEventArgs e)
        {
            if (e.RoutedEvent != MouseMoveEvent)
            {
                Debug.WriteLine(e.RoutedEvent.Name);
            }
        }
    }
}

@axionl
Copy link

axionl commented Jan 14, 2025

I encountered a similar problem, which did not occur on the old version either.

When the Nodify Editor loses focus, such as opening a file dialog box, it cannot capture the LostMouseCapture event, resulting in the left mouse button not being able to select and drag and drop normally.

Before:
图片

After:
图片

Can you try the following code and let me know what's written in the output window? And is it only the StateNode that doesn't work? Did you also try dragging a Node?

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    static MainWindow()
    {
        InputProcessor.Shared<ItemContainer>.RegisterHandlerFactory(editor => new CustomInputHandler());
    }

    private class CustomInputHandler : IInputHandler
    {
        public bool RequiresInputCapture => false;

        public void HandleEvent(InputEventArgs e)
        {
            if (e.RoutedEvent != MouseMoveEvent)
            {
                Debug.WriteLine(e.RoutedEvent.Name);
            }
        }
    }
}

@shiguHa
Copy link
Author

shiguHa commented Jan 14, 2025

@miroiu
I tried the code, and the following was written in the output window.
Normally, "MouseDown".

MouseDown
MouseDown
MouseDown
MouseUp
MouseDown

I also tested with Node, GroupingNode, and KnotNode, but similarly, Node does not move.

@miroiu miroiu linked a pull request Jan 14, 2025 that will close this issue
@miroiu
Copy link
Owner

miroiu commented Jan 14, 2025

@axionl I'll try to reproduce your issue whenever I have time. It would be very helpful if you could provide a minimal code example that demonstrates the problem.

@shiguHa I believe the issue is related to the mouse not being captured for some reason. I’ve created a PR with a potential fix for this. Would you be able to test the fix in the fix/199-drag-item-containers branch and let me know if it resolves the issue?

@shiguHa
Copy link
Author

shiguHa commented Jan 15, 2025

@miroiu
Thank you for fix the source code.
I tried debugging, but it didn't resolve the issue.

I modified the code as shown below, and now the node moves with drag.

Before:

EditorGestures.ItemContainerGestures gestures = EditorGestures.Mappings.ItemContainer;
if (gestures.Drag.Matches(e.Source, e))
{
_isDragging = Element.IsDraggable;
}

After:

 EditorGestures.ItemContainerGestures gestures = EditorGestures.Mappings.ItemContainer; 
 if (true) 
 { 
     _isDragging = Element.IsDraggable; 
 } 

It seems that gestures.Drag.Matches(e.Source,e) is returning False.

I also checked the Matches method of Nodify.Interactivity.InputGestureRef, but since I don't have a full understanding of the entire code, I couldn't identify the cause.

I apologize if I’m saying something off the mark.

@miroiu
Copy link
Owner

miroiu commented Jan 15, 2025

It's the Matches method of the Nodify.Interactivity.MouseGesture that you can debug.

public override bool Matches(object targetElement, InputEventArgs inputEventArgs)
{
if (inputEventArgs is MouseButtonEventArgs || inputEventArgs is MouseWheelEventArgs)
{
bool matches = base.Matches(targetElement, inputEventArgs);
if (IgnoreModifierKeysOnRelease && IsButtonReleased(inputEventArgs))
{
ModifierKeys prevModifiers = Modifiers;
Modifiers = ModifierKeys.None;
matches |= base.Matches(targetElement, inputEventArgs);
Modifiers = prevModifiers;
}
return matches && MatchesKeyboard();
}
return false;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants