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.27k stars 205 forks source link

[Question] Map panning to left mouse button #103

Closed hailstorm75 closed 3 months ago

hailstorm75 commented 3 months ago

I want to allow users to pan within the node editor using the left mouse button.

image

Similarly to, e.g., Blender's tool selection that modifies what the left mouse button does, I wish to introduce three tools for operating the node editor:

image

I've found that the EditorGestures class is public; thus, it is possible to modify the default gestures to something custom.

However, I couldn't figure out how to detach the selection from the left click.

I've tried the following:

EditorGestures.Selection.DefaultMouseAction = MouseAction.None;
EditorGestures.Selection.Replace = new MouseGesture(MouseAction.None);
EditorGestures.Selection.Remove = new MouseGesture(MouseAction.None);
EditorGestures.Selection.Append = new MouseGesture(MouseAction.None);
EditorGestures.Selection.Invert = new MouseGesture(MouseAction.None);

EditorGestures.Pan = new MultiGesture(MultiGesture.Match.Any, new MouseGesture(MouseAction.LeftClick), new MouseGesture(MouseAction.MiddleClick));

Could you please point me in the right direction?

Given how these gestures are implemented, I'd assume it should be fine to modify them during the runtime. Is that correct?

miroiu commented 3 months ago

Hi! You should be able to modify the gestures at runtime, however it seems that the select gesture property is missing the setter. I'll create a PR to address that. Do you build from the source code or from the nuget package?

hailstorm75 commented 3 months ago

I use the NuGet package

miroiu commented 3 months ago

I created the PR and, it looks like not all the gestures were customizable at runtime, especially the ones used for the EditorCommands. Therefore it resulted in more work than expected. Could you please let me know if this suits your needs? I'm open to suggestions and ideas. #104

hailstorm75 commented 3 months ago

Based on the description of the PR, this looks perfect. I shall do some testing today and let you know.

miroiu commented 3 months ago

I merged the PR and will push a new release to NuGet soon. Please feel free to reopen the issue if needed.