# Proposal to change double click event vtk mapping

**URL:** https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120
**Category:** Development
**Created:** [September 1, 2020, 8:10pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120 "2020-09-01T20:10:18Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Davide\_Punzo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/davide_punzo/32/9209_2.png) [@Davide\_Punzo](https://discourse.vtk.org/u/Davide_Punzo)
#### Post date: [September 1, 2020, 8:10pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/1 "2020-09-01T20:10:18Z")

</div>

Hi all,

for 3DSlicer we use different mapping for double clicks in the QVTKInteractor: we differentiate single and double click events, i.e

 ![](https://discourse.vtk.org/uploads/default/original/2X/9/94cd728eaf9e43b75060e9e0bf2f332314aa46d0.png)

We would like to merge this PR in vtk upstream since @jcfr is updating the Slicer VTK branch.

We tested the PR around one year ago and at the time we didn’t see any issue with VTK widgets or views. However, we are concerned that the PR can break some applications. Please let us know if there would be any issue or if you would like to keep the previous mapping (single clicks and double clicks having the same event).

Thanks,

Davide.

MR: [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/7193](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7193)  
for reference: [https://github.com/Slicer/Slicer/pull/5141#discussion\_r479690583](https://github.com/Slicer/Slicer/pull/5141#discussion_r479690583)

---

<div class="post-metadata">

### Author: ![jcfr](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jcfr/32/466_2.png) [@jcfr](https://discourse.vtk.org/u/jcfr)
#### Post date: [September 30, 2020, 12:03am UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/2 "2020-09-30T00:03:21Z")

</div>

To follow up this, unless there are objections we will shortly move forward with the integration of the corresponding merge request.

---

<div class="post-metadata">

### Author: ![jcfr](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jcfr/32/466_2.png) [@jcfr](https://discourse.vtk.org/u/jcfr)
#### Post date: [October 13, 2020, 8:40pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/3 "2020-10-13T20:40:52Z")

</div>

Corresponding topic has just been merged.

---

<div class="post-metadata">

### Author: ![Davide\_Punzo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/davide_punzo/32/9209_2.png) [@Davide\_Punzo](https://discourse.vtk.org/u/Davide_Punzo)
#### Post date: [October 14, 2020, 8:26am UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/4 "2020-10-14T08:26:56Z")

</div>

Thanks!

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [October 15, 2020, 3:22pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/5 "2020-10-15T15:22:01Z")

</div>

No objections, but this seems to have broken some other things in VTK and ParaView.

Specifically, `vtkControlPointsItem::MouseDoubleClickEvent` is no longer invoked because `vtkContextScene::DoubleClickEvent` is not invoked because `vtkContextInteractorStyle::ProcessMousePress` is asking `vtkRenderWindowInteractor` for its `RepeatCount` and never getting anything \> 1.

@Davide_Punzo @jcfr , do you know what about the MR could have changed processing in VTK’s Rendering/Context2D ?

---

<div class="post-metadata">

### Author: ![Davide\_Punzo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/davide_punzo/32/9209_2.png) [@Davide\_Punzo](https://discourse.vtk.org/u/Davide_Punzo)
#### Post date: [October 15, 2020, 5:34pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/6 "2020-10-15T17:34:42Z")

</div>

Hi @dcthomp, I could reproduce as well, thanks for reporting!

I have to say that I am not sure where the RepeatCount is increased to 1. It seems that it is required the invoke of single button press also in the double click ones, something like this:

```auto
else if (t == QEvent::MouseButtonDblClick)
    {
      switch (e2->button())
      {
        case Qt::LeftButton:
          iren->InvokeEvent(vtkCommand::LeftButtonPressEvent, e2);
          iren->InvokeEvent(vtkCommand::LeftButtonDoubleClickEvent, e2);
          break;

        case Qt::MidButton:
          iren->InvokeEvent(vtkCommand::MiddleButtonPressEvent, e2);
          iren->InvokeEvent(vtkCommand::MiddleButtonDoubleClickEvent, e2);
          break;

        case Qt::RightButton:
          iren->InvokeEvent(vtkCommand::RightButtonPressEvent, e2);
          iren->InvokeEvent(vtkCommand::RightButtonDoubleClickEvent, e2);
          break;

        default:
          break;
      }
    }

```

of course, having two signals for the same event will not be optimal.  
I’ll try to investigate asap.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [October 15, 2020, 5:35pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/7 "2020-10-15T17:35:22Z")

</div>

I have a merge request up now:

[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/7333](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7333)

How does that compare to this?

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [October 15, 2020, 5:38pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/8 "2020-10-15T17:38:52Z")

</div>

@Davide_Punzo I tried to add you as a reviewer to the MR but couldn’t find your gitlab account (assuming you have one, which you may not).

---

<div class="post-metadata">

### Author: ![Davide\_Punzo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/davide_punzo/32/9209_2.png) [@Davide\_Punzo](https://discourse.vtk.org/u/Davide_Punzo)
#### Post date: [October 15, 2020, 5:42pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/9 "2020-10-15T17:42:28Z")

</div>

not using the gitlab account tto much indeed 🙂 . It is this one: [https://gitlab.kitware.com/Punzo](https://gitlab.kitware.com/Punzo)

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [October 22, 2020, 6:29pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/10 "2020-10-22T18:29:07Z")

</div>

@Davide_Punzo The change you suggest might be better than nothing, but it feels like it could also cause problems should an application be listening for single-click events. Without at least updating the RepeatCount to 1 before invoking `vtkCommand::xxxButtonPressEvent`, this seems problematic.

I’ve merged my change, which simply ensures that double-click events are passed to interactor styles and updates one subclass (`vtkContextInteractorStyle`) to pay attention to them.

@simonesneault I looked at `vtkImagePlaneWidget` but didn’t see RepeatCount in use anywhere in the file or even in `Interaction/Widgets`. What does double-click do for the image-plane widget?

---

<div class="post-metadata">

### Author: ![Davide\_Punzo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/davide_punzo/32/9209_2.png) [@Davide\_Punzo](https://discourse.vtk.org/u/Davide_Punzo)
#### Post date: [October 22, 2020, 10:51pm UTC](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/11 "2020-10-22T22:51:14Z")

</div>

> [@dcthomp](#):
>
> @Davide_Punzo The change you suggest might be better than nothing, but it feels like it could also cause problems should an application be listening for single-click events. Without at least updating the RepeatCount to 1 before invoking `vtkCommand::xxxButtonPressEvent` , this seems problematic.

The repeatCount is equal to 1 when the vtkCommand::xxxButtonPressEvent is fired in the if condition QEvent::MouseButtonDblClick in the [temp solution](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/6) (I really didn’t undestrand why and where it gets update to 1), so one can distinguish vtkCommand::xxxButtonPressEvent from single and double clicks.

But again, I agree with you and I don’t like the [temp solution](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/6): it’s dirty and would confuse developers to have two double clicks events “systems”. I would prefer to have just vtkCommand::xxxButtonDoubleClickEvent at QEvent::MouseButtonDblClick events (current status) and remove the repeatCount ivar along VTK (by updating it where necessary). On the other hand, I don’t have time to address this properly now, and the [temp solution](https://discourse.vtk.org/t/proposal-to-change-double-click-event-vtk-mapping/4120/6) may help with the transition.

> [@dcthomp](#):
>
> I’ve merged my change, which simply ensures that double-click events are passed to interactor styles and updates one subclass ( `vtkContextInteractorStyle` ) to pay attention to them.

great, thanks!
