AB4D Forum
Event handler - 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: Event handler (/showthread.php?tid=4180)



Event handler - kreativasas - 03-18-2020

Hi everybody,
I created an Eventmanager 3d with a visualeventsource3d and added an handler on a 3dview.MouseLeftButtonDown.
If i click on a object the eventhandler give control to the visualevent and everything is ok. But i need to raise the event also when is clicked a empy part of the 3dview.

Is it possible?
Thanks for reply


RE: Event handler - kreativasas - 03-19-2020

Any suggestion??


RE: Event handler - abenedik - 03-20-2020

With EventManager3D you will be only able to get events when mouse is over the subscribed 3D objects.

To get mouse events when over the empty area, you will need to use manually hit testing instead of using EventManager3D. To do this, you will need to subscribe to mouse events on a Border or any other parent object from Viewport3D (if you subscribe to mouse events on Viewport3D, you will only get them when mouse is over any 3D object). The parent Border or other parent object need to have the Background property set (it can be set to Transparent). If the Background property is not set, then this area is not "occupied" by the Border or any other object.

When you are subscribed to mouse events, then check the "Standard WPF hit testing sample" that comes with Ab3d.PowerToys samples (EventManager3D\StandardWpfHitTestingDemo.xaml.cs) to see how to get hit 3D objects.

Note that if you will want to use the same mouse events for hit testing and for camera rotation and movement (for MouseCameraController), you will need to subscribe to PreviewMouse... events (so PreviewMouseDown instead of MouseDown). See the MouseSelectionAndRotation for more info about that.


RE: Event handler - kreativasas - 03-24-2020

Many Thanks!