Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic MouseWheel event does not work in DiagramView. (Read 1406 times)
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
MouseWheel event does not work in DiagramView.
Mar 14th, 2024 at 5:01am
Print Post  
Hello, Mindfusion team. I have some custom logic in my application related to the MouseWheel event (Zoom in, Zoom out). It worked properly in the Diagram class until I put it in a DiagramView. I thought I could handle it by using MouseWheel event on DiagramView, but it is not firing as well. How can I use such events with updated layout?
  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: MouseWheel event does not work in DiagramView.
Reply #1 - Mar 14th, 2024 at 6:33am
Print Post  
Also I have custom MoveNodesBehavior in my application, which seems to not work after adding a diagram into DiagramView
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3440
Joined: Oct 19th, 2005
Re: MouseWheel event does not work in DiagramView.
Reply #2 - Mar 14th, 2024 at 12:31pm
Print Post  
Hi,

MouseWheel event seems intercepted by the embedded ScrollViewer, maybe with older version you were setting some property on the Diagram's parent ScrollViewer to prevent that. With current version I got wheel handling working via Preview version of the event instead:

Code
Select All
<diag:DiagramView
    x:Name="diagramView"
    PreviewMouseWheel="OnPreviewMouseWheel">

        <diag:Diagram x:Name="diagram" />

</diag:DiagramView>

void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
    Debug.WriteLine("OnPreviewMouseWheel");

    var viewPoint = e.GetPosition(diagramView);
    var diagPoint = diagramView.ViewToDiagram(viewPoint);
    diagramView.SetZoomFactor(
        diagramView.ZoomFactor + 5, diagPoint);

    e.Handled = true;
} 



As for behaviors, make sure you are setting DiagramView.Behavior property now. Old Diagram.Behavior should display warning if used. Additionally, in custom behavior implementation call ViewToDiagram method to convert mouse coordinates, instead of e.GetPosition(diagram.DocumentPlane) from older versions.

Regards,
Slavcho
Mindfusion
  

WheelTest.zip ( 3 KB | 120 Downloads )
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint