# callback set on vtkWidgetCallbackMapper - vtkCommand::MouseMoveEvent working randomely in vtk 9

**URL:** https://discourse.vtk.org/t/callback-set-on-vtkwidgetcallbackmapper-vtkcommand-mousemoveevent-working-randomely-in-vtk-9/16342
**Category:** Development
**Created:** [March 18, 2026, 6:45pm UTC](https://discourse.vtk.org/t/callback-set-on-vtkwidgetcallbackmapper-vtkcommand-mousemoveevent-working-randomely-in-vtk-9/16342 "2026-03-18T18:45:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)
#### Post date: [March 18, 2026, 6:45pm UTC](https://discourse.vtk.org/t/callback-set-on-vtkwidgetcallbackmapper-vtkcommand-mousemoveevent-working-randomely-in-vtk-9/16342/1 "2026-03-18T18:45:53Z")

</div>

Code snippet

================

-\>CallbackMapper-\>SetCallbackMethod(vtkCommand::MouseMoveEvent,  
vtkWidgetEvent::Move,  
this, vtkOrientationBoxMarkerWidget::MoveAction);

The callback was working perfectly in vtk 5 but not in vtk 9 - hitting occationally.

Any alternatives to invoke mouseMove/ or any other better way?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 19, 2026, 6:14pm UTC](https://discourse.vtk.org/t/callback-set-on-vtkwidgetcallbackmapper-vtkcommand-mousemoveevent-working-randomely-in-vtk-9/16342/2 "2026-03-19T18:14:01Z")

</div>

Hello,

Well, a modern way to implement what you want is to derive `vtkInteractorStyleTrackballCamera`.

Here’s an example: [gammaray/viewer3d/v3dmouseinteractor.h at master · PauloCarvalhoRJ/gammaray · GitHub](https://github.com/PauloCarvalhoRJ/gammaray/blob/master/viewer3d/v3dmouseinteractor.h) [gammaray/viewer3d/v3dmouseinteractor.cpp at master · PauloCarvalhoRJ/gammaray · GitHub](https://github.com/PauloCarvalhoRJ/gammaray/blob/master/viewer3d/v3dmouseinteractor.cpp) and an example of how to use it:

```cpp
// Customize event handling through a subclass of vtkInteractorStyleTrackballCamera.
// This allows picking and probing by clicking on objects in the scene, for example.
m_myInteractor = vtkSmartPointer<v3dMouseInteractor>::New();
m_myInteractor->SetDefaultRenderer(m_renderer);
m_vtkwidget->renderWindow()->GetInteractor()->SetInteractorStyle( m_myInteractor );

```

I hope this helps you update your VTK 5 code.

best,

PC
