AB4D Forum
MouseCameraController rotation with left button pressed OR with right button pressed - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: MouseCameraController rotation with left button pressed OR with right button pressed (/showthread.php?tid=4125)



MouseCameraController rotation with left button pressed OR with right button pressed - luigi.oliveto@gmail.com - 02-12-2019

Hello,

I'm using the MouseCameraController to move/rotate a target position camera into a Viewport3D.

My problem is that I would like to enable camera rotation with mouse left button click OR with mouse right button click at the same time.

Is this a FEATURE that you're going to introduce in some future release?

Thank you for your time.

Best.
Luigi Oliveto


RE: MouseCameraController rotation with left button pressed OR with right button pressed - abenedik - 02-13-2019

With using PreviewMouseDown event it is possible to check which button is pressed before this event gets processed by the MouseCameraController. This means that it is possible to update the RotateCameraConditions based on the currently pressed mouse button:

            ViewportBorder.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e)
            {
                if (e.LeftButton == MouseButtonState.Pressed && e.RightButton == MouseButtonState.Released)
                {
                    MouseCameraController1.RotateCameraConditions = MouseCameraController.MouseAndKeyboardConditions.LeftMouseButtonPressed;
                }
                else if (e.LeftButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Pressed)
                {
                    MouseCameraController1.RotateCameraConditions = MouseCameraController.MouseAndKeyboardConditions.RightMouseButtonPressed;
                }
                else if (e.LeftButton == MouseButtonState.Pressed && e.RightButton == MouseButtonState.Pressed)
                {
                    MouseCameraController1.RotateCameraConditions = MouseCameraController.MouseAndKeyboardConditions.LeftMouseButtonPressed | MouseCameraController.MouseAndKeyboardConditions.RightMouseButtonPressed;
                }
            };

With the new version of Ab3d.PowerToys (I am planning to release it this week or in the beginning of the next week) it will be also possible to override the IsMouseButtonsConditionTrue and IsKeyboardConditionTrue methods and provide your own logic there.


RE: MouseCameraController rotation with left button pressed OR with right button pressed - luigi.oliveto@gmail.com - 02-14-2019

Thank you so much, it worked perfectly!