# Get state of widget

**URL:** <https://discourse.vtk.org/t/get-state-of-widget/13580>\
**Category:** Development\
**Tags:** python\
**Created:** [March 19, 2024, 8:46am UTC](https://discourse.vtk.org/t/get-state-of-widget/13580 "2024-03-19T08:46:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.vtk.org/u/zhangm)\
**Post date:** [March 19, 2024, 8:46am UTC](https://discourse.vtk.org/t/get-state-of-widget/13580/1 "2024-03-19T08:46:57Z")

</div>

I create a vtkContourWidget instance, and I want to know if the mouse is hovering near the endpoint of contour. The code like this:

```auto
pos = interactor.GetEventPosition()
state = contourRep.ComputeInteractionState(pos[0], pos[1])

```

Even though I move mouse on the endpoint, the state always return 0. Is my function is wrong or send the wrong parameter to ComputeInteractionState().  
To determine if it is due to the incorrect position passed in by the mouse，I have traversed all endpoints on the cntour, and only the first endpoint returned a state value of 1.

```auto
num = contourRep.GetNumberOfNodes()
for i in range(num):
    pos = [0, 0]
    contourRep.GetNthNodeDisplayPosition(i, pos)
    print(i, contourRep.ComputeInteractionState(int(pos[0]), int(pos[1])))

```

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.vtk.org/u/zhangm)\
**Post date:** [March 21, 2024, 9:14am UTC](https://discourse.vtk.org/t/get-state-of-widget/13580/2 "2024-03-21T09:14:04Z")

</div>

I still didn’t find why the value of `ComputeInteractionState(pos)` returns is not I want. But I find a new function `GetActiveNodeDisplayPosition(pos)` that can sovle my problem. When mouse on the endpoint, this function will return 1.
