miroiu / nodify

Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
https://miroiu.github.io/nodify
MIT License
1.3k stars 208 forks source link

[Bug] Trying to implement OperationsMenuView in mulitiple instance of nodify editor #66

Closed KaivnD closed 1 year ago

KaivnD commented 1 year ago

Hi! I have some trouble with trying to implement OperationsMenuView in mulitiple instance of nodify editor, the EventManager.RegisterClassHandler not acting right, like this.

https://github.com/miroiu/nodify/assets/37983330/cda4a339-2578-420b-b485-69f092eb74f3

and here is my code. WpfApp2.zip

KaivnD commented 1 year ago

updates: just try bind mouse event like this, it works, but editor.IsPanning is true even I'm not paning.

        <nodify:NodifyEditor
            x:Name="Editor"
            MouseLeftButtonDown="Editor_MouseLeftButtonDown"
            MouseRightButtonDown="Editor_MouseRightButtonDown"
            ......
    private void Editor_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
    {
        if (e.Handled || sender is not NodifyEditor editor) return;
        if (DataContext is not NodeEditorViewModel vm) return;
        if (!editor.IsPanning)
        {
            e.Handled = true;
            vm.Library.OpenAt(editor.MouseLocation);
        }
    }
KaivnD commented 1 year ago

updates: my bad! that's so stupid. I should bind MouseRightButtonUp instead of MouseRightButtonDown, problem solved!