# Create, invoke and observe vtk custom event

**URL:** <https://discourse.slicer.org/t/create-invoke-and-observe-vtk-custom-event/11794>\
**Category:** Development\
**Created:** [May 30, 2020, 2:09pm UTC](https://discourse.slicer.org/t/create-invoke-and-observe-vtk-custom-event/11794 "2020-05-30T14:09:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 30, 2020, 4:54pm UTC](https://discourse.slicer.org/t/create-invoke-and-observe-vtk-custom-event/11794/2 "2020-05-30T16:54:26Z")

</div>

Hi Paolo -

Good point - right now you get the same ModifiedEvent no matter what parameter changed. You would need to keep track of the old values and check which one had changed.

Currently we just call `Modified` in `SetParameter`, but we could change that to be `this->InvokeEvent(vtkCommand::ModifiedEvent, name)`

> <https://github.com/Slicer/Slicer/blob/421d1c06a9ac4ead72bdd338dd7358ea48008b25/Libs/MRML/Core/vtkMRMLScriptedModuleNode.cxx#L144>

Then you should be able to get the parameter using the method described [here](https://discourse.slicer.org/t/custom-events-for-vtk/1286/3)

> [@Custom Events for VTK](https://discourse.slicer.org/t/custom-events-for-vtk/1286/3):
>
> For some types of data can add a decorator to your callback that interprets the call data in python. [https://github.com/Kitware/VTK/blob/master/Wrapping/Python/vtk/util/misc.py#L6-L27](https://github.com/Kitware/VTK/blob/master/Wrapping/Python/vtk/util/misc.py#L6-L27) For most data types in Slicer, a vtkObject is actually returned as a wrapped version of whatever concrete subclass was passed in the payload, so it actually covers all slicer events that come from nodes or the scene or other classes. You can also call InvokeEvent from python with a calldata (payload) argument. …

---

_[View the full topic](https://discourse.slicer.org/t/create-invoke-and-observe-vtk-custom-event/11794)._
