# List control, property change generates two events

**URL:** <https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735>\
**Category:** Ignition\
**Created:** [March 8, 2011, 11:10am UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735 "2011-03-08T11:10:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkimber](https://avatars.discourse-cdn.com/v4/letter/p/a88e4f/32.png) [@pkimber](https://forum.inductiveautomation.com/u/pkimber)\
**Post date:** [March 8, 2011, 11:10am UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735/1 "2011-03-08T11:10:49Z")

</div>

I have the following code in the property change event handler for a single select list:

```auto
if event.propertyName == 'selectedIndex':
    print event.source.selectedIndex
```

Two events are generated as I click on each item in the list box. Here is some sample output:

```auto
3
3
2
2
4
4
```

I think this issue has been highlighted before (“One other thing- working with Colby the other day, we found that the List.selectedIndex property change generates two events instead of one”). For details see:  
[http://www.inductiveautomation.com/forum/viewtopic.php?f=23&t=3974&p=7685&hilit=list+selectedIndex#p7685](http://www.inductiveautomation.com/forum/viewtopic.php?f=23&t=3974&p=7685&hilit=list+selectedIndex#p7685)

Is this correct behaviour? If it is, can you suggest a simple workaround so I can get a single event for a single click?

We are using Ignition version 7.2.3 (b6630).

Thank you for your help,

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [March 8, 2011, 8:25pm UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735/2 "2011-03-08T20:25:07Z")

</div>

You can work around this issue with a client property.

```auto
if event.propertyName == 'selectedIndex':
    if event.newValue != event.source.getClientProperty("LastIndex"):
        print event.source.selectedIndex
        event.source.putClientProperty("LastIndex",event.newValue)
```

---

<div class="post-metadata">

**Author:** ![pkimber](https://avatars.discourse-cdn.com/v4/letter/p/a88e4f/32.png) [@pkimber](https://forum.inductiveautomation.com/u/pkimber)\
**Post date:** [March 9, 2011, 2:58pm UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735/3 "2011-03-09T14:58:55Z")

</div>

Hello Kyle,

Thank you very much for the work around. My property change event is working perfectly now.

I can’t find any details of the methods:

```auto
event.source.getClientProperty
event.source.putClientProperty
```

…in the Ignition documentation. Is this working directly with dynamic properties?

Thank you again for your help,

Patrick

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [March 10, 2011, 12:51am UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735/4 "2011-03-10T00:51:35Z")

</div>

All the components in Ignition are extensions of JComponents.  
[http://download.oracle.com/javase/6/docs/api/javax/swing/JComponent.html](http://download.oracle.com/javase/6/docs/api/javax/swing/JComponent.html)

As such, most methods available to a JComponent will be available to Ignition Components, unless they are over-ridden.

Because the scripts we write are written in Jython, we can access the Java methods and constructors through Jython.

To list all the methods available to a certain component, you can do the following:

`methods = event.source.parent.getComponent('Pie Chart').class.getMethods()
data = []
for method in methods:
	data.append([method])
event.source.parent.getComponent('Table').data = system.dataset.toDataSet(["Methods"],data)
    `

You can do the same for constructors, fields, etc.

---

<div class="post-metadata">

**Author:** ![pkimber](https://avatars.discourse-cdn.com/v4/letter/p/a88e4f/32.png) [@pkimber](https://forum.inductiveautomation.com/u/pkimber)\
**Post date:** [March 10, 2011, 3:59pm UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735/5 "2011-03-10T15:59:47Z")

</div>

Thank you again Kyle. I am sure this will be very useful in future.

I am interested to see if we can store an instance of a jython class in the client properties of a control. I will try it out as soon as I get some time.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [March 10, 2011, 4:50pm UTC](https://forum.inductiveautomation.com/t/list-control-property-change-generates-two-events/2735/6 "2011-03-10T16:50:34Z")

</div>

Yeah, you can do something like that. For example, if I wanted to set a global reference to a Java Color or something else, you can do that like this

`from java.awt import Color
global testColor
testColor = Color(255,255,255,0)
`

To use this in another script, you can do the following

`Global testColor
print testColor`

Color, itself is a Java Object, so this will work for other things, such as JFrames, Ignition components, etc.
