LeftButtonPressEvent of vtkResliceCursorWidget

Hello, I’m using Activiz with the vtkResliceCursorWidget. However when I register to the LeftButtonPressEvt, the handler is never invoked. In my application I need to propagate these events, so the parent controls know that something was clicked. It works with the RenderWindow, but as soon as I have a widget they seem to swallow all events. Is this even possible?


Can you, please, share the code of what you’re trying?



One thing that is a common cause of “swallowed events” is not forwarding them to the base class (I assume you are deriving a default event handling class). Here’s an example:

void v3dMouseInteractor::OnMouseMove()
    if( m_isLBdown )
        m_isDragging = true;

    // Forward the event to the base class.

In this example, my class v3dMouseInteractor derives VTK’s vtkInteractorStyleTrackballCamera so I can customize the behavior of the default mouse interactor. If I don’t forward the event to the base class, the rest of the mechanics of event handling is skipped, including possible other event hendlers. This rationale applies to many event-driven APIs and is likely the case of whatever you’re using.

Hi Paulo,

thanks for your response. I actually don’t use subclasses at all, I simply register to the events of the interactor, e.g. LeftButtonPressEvt. This works fine for the vtkRenderWindow, when I click into the window the event is called.
However if I click on a widget (e.g. vtkResliceCursorWidget), the widget seems to completely swallow the event and the click handler of the renderwindow is not called. The vtkResliceCursorWidget exposes an event LeftButtonPressEvt, but that handler is never called upon clicking.
I think my issue is similar to this one: LeftButtonPressEvent to vtkButtonWidget
I can provide a code sample shortly.


It’s intrinsic for the widget to intercept mouse events. You can disable any widgets via some button of the program’s UI, so the events reach the window interactor. Activating/de-activating widgets is quite common in software that feature a 3D viewer. Below, it’s the UI of a software called SKUA (v. 2019) used in the petroleum industry:
The green icon indicates the slicer (equivalent to VTK’s vtkResliceCursorWidget) is active, so, if I drag the mouse over the model, the slicer tool translates following the mouse pointer. If I need to rotate the model, I need to disable it (icon turns red) so when I drag the mouse, the model screen receives the events (equivalent to VTK’s window interactor). This is quite normal in 3D UI designs.

You can for instance define a keyboard shortcut to enable/disable the widget quickly.