# Interactor from old version to 4.10.2

**URL:** https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493
**Category:** Support
**Created:** [December 14, 2019, 1:34am UTC](https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493 "2019-12-14T01:34:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fraca](https://avatars.discourse-cdn.com/v4/letter/f/f19dbf/32.png) [@fraca](https://discourse.slicer.org/u/fraca)
#### Post date: [December 14, 2019, 1:34am UTC](https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493/1 "2019-12-14T01:34:56Z")

</div>

Hi, i’m try to convert this code that was build for 3DSlicer 3.6 to the newest 3DSlicer 4.10.2, but i have some issues to define the interactor.  
Can you help me?

> self.RedSliceInteractor=slicer.ApplicationGUI.GetMainSliceGUI(“Red”).GetSliceViewer().GetRenderWidget().GetRenderWindowInteractor()  
> self.RedSliceLeftButtonReleaseTag=self.RedSliceInteractor.AddObserver(“LeftButtonReleaseEvent”,self.HandleClickInRedSlice)

This is a part of the function that needs the interactor:

> def HandleClickInRedSlice(self):  
> if not self.Selecting:  
> return  
> coordinates = self.RedSliceInteractor.GetLastEventPosition()  
> ctrlKey = self.RedSliceInteractor.GetControlKey()

I’m trying to observe the mouse left-click on the Red Slice of 3DSlicer, and i have also to check if Ctrl-key is pressed and to take the coordinates on the image of the point pressed

---

<div class="post-metadata">

### Author: ![fraca](https://avatars.discourse-cdn.com/v4/letter/f/f19dbf/32.png) [@fraca](https://discourse.slicer.org/u/fraca)
#### Post date: [December 14, 2019, 1:34am UTC](https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493/2 "2019-12-14T01:34:53Z")

</div>

Hi, i’m trying to update this code (build for 3DSlicer 3.6) for 3DSlicer 4.10.2 but i have some issues with the interactor. I want to observe the “LeftButtonReleaseEvent” when i press only on the Red Slice Viewer (in 3DSlicer).

> self.RedSliceInteractor=slicer.ApplicationGUI.GetMainSliceGUI(“Red”).GetSliceViewer().GetRenderWidget().GetRenderWindowInteractor() self.RedSliceLeftButtonReleaseTag=self.RedSliceInteractor.AddObserver(“LeftButtonReleaseEvent”,self.HandleClickInRedSlice)

This is the first part of the function that i call above:

> def HandleClickInRedSlice(self):  
> if not self.Selecting:  
> return  
> coordinates = self.RedSliceInteractor.GetLastEventPosition()  
> ctrlKey = self.RedSliceInteractor.GetControlKey()

So i want to obatin also the coordinates of the point where i clicked and i i pressed the Ctrl key.  
Can you help me?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [December 15, 2019, 6:08am UTC](https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493/3 "2019-12-15T06:08:36Z")

</div>

Interactors are hard. I would not recommend to implement features at such low level but instead utilize Markups widgets to define point positions, lines, curves, etc. See examples in script repository: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Manipulating\_objects\_in\_the\_slice\_viewer](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Manipulating_objects_in_the_slice_viewer)

---

<div class="post-metadata">

### Author: ![fraca](https://avatars.discourse-cdn.com/v4/letter/f/f19dbf/32.png) [@fraca](https://discourse.slicer.org/u/fraca)
#### Post date: [December 17, 2019, 11:46am UTC](https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493/4 "2019-12-17T11:46:30Z")

</div>

Thanks for your suggestion. There’s a way to run a function when i create only one markup node with mouse-click? I tried to do something with `AddObserver`, but i found some issues.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [December 17, 2019, 1:07pm UTC](https://discourse.slicer.org/t/interactor-from-old-version-to-4-10-2/9493/5 "2019-12-17T13:07:59Z")

</div>

See working examples in the script repository, for example: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Manipulating\_objects\_in\_the\_slice\_viewer](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Manipulating_objects_in_the_slice_viewer)
